Search in sources :

Example 1 with JobAlreadyFinishedException

use of org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException in project scheduling by ow2-proactive.

the class SchedulerStateRest method schedulerChangeJobPriorityByValue.

/**
 * changes the priority of a job
 *
 * @param sessionId
 *            a valid session id
 * @param jobId
 *            the job id
 * @param priorityValue
 *            a string representing the value of the priority
 * @throws NumberFormatException
 * @throws NotConnectedRestException
 * @throws UnknownJobRestException
 * @throws PermissionRestException
 * @throws JobAlreadyFinishedRestException
 */
@Override
@PUT
@Path("jobs/{jobid}/priority/byvalue/{value}")
public void schedulerChangeJobPriorityByValue(@HeaderParam("sessionid") final String sessionId, @PathParam("jobid") final String jobId, @PathParam("value") String priorityValue) throws NumberFormatException, NotConnectedRestException, UnknownJobRestException, PermissionRestException, JobAlreadyFinishedRestException {
    try {
        Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/priority/byvalue" + priorityValue);
        s.changeJobPriority(jobId, JobPriority.findPriority(Integer.parseInt(priorityValue)));
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    } catch (JobAlreadyFinishedException e) {
        throw new JobAlreadyFinishedRestException(e);
    } catch (UnknownJobException e) {
        throw new UnknownJobRestException(e);
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) JobAlreadyFinishedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.JobAlreadyFinishedRestException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) Path(javax.ws.rs.Path) PUT(javax.ws.rs.PUT)

Example 2 with JobAlreadyFinishedException

use of org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException in project scheduling by ow2-proactive.

the class SchedulerStateRest method schedulerChangeJobPriorityByName.

/**
 * changes the priority of a job
 *
 * @param sessionId
 *            a valid session id
 * @param jobId
 *            the job id
 * @param priorityName
 *            a string representing the name of the priority
 * @throws NotConnectedRestException
 * @throws UnknownJobRestException
 * @throws PermissionRestException
 * @throws JobAlreadyFinishedRestException
 */
@Override
@PUT
@Path("jobs/{jobid}/priority/byname/{name}")
public void schedulerChangeJobPriorityByName(@HeaderParam("sessionid") final String sessionId, @PathParam("jobid") final String jobId, @PathParam("name") String priorityName) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException, JobAlreadyFinishedRestException {
    try {
        Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/priority/byname/" + priorityName);
        s.changeJobPriority(jobId, JobPriority.findPriority(priorityName));
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    } catch (JobAlreadyFinishedException e) {
        throw new JobAlreadyFinishedRestException(e);
    } catch (UnknownJobException e) {
        throw new UnknownJobRestException(e);
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) JobAlreadyFinishedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.JobAlreadyFinishedRestException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) Path(javax.ws.rs.Path) PUT(javax.ws.rs.PUT)

Example 3 with JobAlreadyFinishedException

use of org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException in project scheduling by ow2-proactive.

the class SchedulerFrontendState method checkChangeJobPriority.

synchronized void checkChangeJobPriority(JobId jobId, JobPriority priority) throws NotConnectedException, UnknownJobException, PermissionException, JobAlreadyFinishedException {
    checkPermissions("changeJobPriority", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_CHANGE_THE_PRIORITY_OF_THIS_JOB);
    UserIdentificationImpl ui = identifications.get(PAActiveObject.getContext().getCurrentRequest().getSourceBodyID()).getUser();
    try {
        ui.checkPermission(new ChangePriorityPermission(priority.getPriority()), ui.getUsername() + " does not have permissions to set job priority to " + priority);
    } catch (PermissionException ex) {
        logger.info(ex.getMessage());
        throw ex;
    }
    if (jobs.get(jobId).isFinished()) {
        String msg = " is already finished";
        jlogger.info(jobId, msg);
        throw new JobAlreadyFinishedException("Job " + jobId + msg);
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl) ChangePriorityPermission(org.ow2.proactive.scheduler.permissions.ChangePriorityPermission) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)

Aggregations

JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)3 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)3 PUT (javax.ws.rs.PUT)2 Path (javax.ws.rs.Path)2 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)2 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)2 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)2 JobAlreadyFinishedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.JobAlreadyFinishedRestException)2 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)2 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)2 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)2 UserIdentificationImpl (org.ow2.proactive.scheduler.job.UserIdentificationImpl)1 ChangePriorityPermission (org.ow2.proactive.scheduler.permissions.ChangePriorityPermission)1