Search in sources :

Example 1 with ChangePriorityPermission

use of org.ow2.proactive.scheduler.permissions.ChangePriorityPermission in project scheduling by ow2-proactive.

the class SchedulerFrontendState method createJob.

synchronized InternalJob createJob(Job userJob, UserIdentificationImpl ident) throws NotConnectedException, PermissionException, SubmissionClosedException, JobCreationException {
    UniqueID id = checkAccess();
    // get the internal job.
    InternalJob job = InternalJobFactory.createJob(userJob, this.credentials.get(id));
    // setting job informations
    if (job.getTasks().size() == 0) {
        String msg = "Job " + job.getId().value() + " contains no task. You need to insert at least one task before submitting job";
        logger.info(msg);
        throw new JobCreationException(msg);
    }
    // job.
    try {
        ident.checkPermission(new ChangePriorityPermission(job.getPriority().ordinal()), ident.getUsername() + " does not have rights to set job priority " + job.getPriority());
    } catch (PermissionException ex) {
        logger.info(ex.getMessage());
        throw ex;
    }
    // setting the job properties
    job.setOwner(ident.getUsername());
    return job;
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) UniqueID(org.objectweb.proactive.core.UniqueID) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) ChangePriorityPermission(org.ow2.proactive.scheduler.permissions.ChangePriorityPermission)

Example 2 with ChangePriorityPermission

use of org.ow2.proactive.scheduler.permissions.ChangePriorityPermission 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

PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)2 ChangePriorityPermission (org.ow2.proactive.scheduler.permissions.ChangePriorityPermission)2 UniqueID (org.objectweb.proactive.core.UniqueID)1 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)1 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)1 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)1 UserIdentificationImpl (org.ow2.proactive.scheduler.job.UserIdentificationImpl)1