use of org.ow2.proactive.scheduler.common.exception.PermissionException in project scheduling by ow2-proactive.
the class SchedulerFrontendState method checkChangePolicy.
synchronized void checkChangePolicy() throws NotConnectedException, PermissionException {
UniqueID id = checkAccess();
UserIdentificationImpl ident = identifications.get(id).getUser();
// renew session for this user
renewUserSession(id, ident);
try {
ident.checkPermission(new ChangePolicyPermission(), ident.getUsername() + " does not have permissions to change the policy of the scheduler");
} catch (PermissionException ex) {
logger.info(ex.getMessage());
throw ex;
}
}
use of org.ow2.proactive.scheduler.common.exception.PermissionException 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;
}
use of org.ow2.proactive.scheduler.common.exception.PermissionException in project scheduling by ow2-proactive.
the class SchedulerFrontendState method addEventListener.
synchronized SchedulerState addEventListener(SchedulerEventListener sel, boolean myEventsOnly, boolean getCurrentState, SchedulerEvent... events) throws NotConnectedException, PermissionException {
// checking permissions
ListeningUser uIdent = checkPermissionReturningListeningUser("addEventListener", YOU_DO_NOT_HAVE_PERMISSION_TO_ADD_A_LISTENER);
// check if listener is not null
if (sel == null) {
String msg = "Scheduler listener must be not null";
logger.info(msg);
throw new IllegalArgumentException(msg);
}
// check if the listener is a reified remote object
if (!MOP.isReifiedObject(sel)) {
String msg = "Scheduler listener must be a remote object";
logger.info(msg);
throw new IllegalArgumentException(msg);
}
// get the scheduler State
SchedulerState currentState = null;
if (getCurrentState) {
// check get state permission is checked in getState method
currentState = getState(myEventsOnly);
} else {
// check get state permission
handleOnlyMyJobsPermission(myEventsOnly, uIdent.getUser(), YOU_DO_NOT_HAVE_PERMISSION_TO_ADD_A_LISTENER);
}
// prepare user for receiving events
uIdent.getUser().setUserEvents(events);
// set if the user wants to get its events only or every events
uIdent.getUser().setMyEventsOnly(myEventsOnly);
// add the listener to the list of listener for this user.
UniqueID id = PAActiveObject.getContext().getCurrentRequest().getSourceBodyID();
uIdent.setListener(new ClientRequestHandler(this, id, sel));
// cancel timer for this user : session is now managed by events
uIdent.getUser().getSession().cancel();
// return to the user
return currentState;
}
use of org.ow2.proactive.scheduler.common.exception.PermissionException in project scheduling by ow2-proactive.
the class SchedulerFrontendState method getJobState.
synchronized JobState getJobState(JobId jobId) throws NotConnectedException, UnknownJobException, PermissionException {
checkPermissions("getJobState", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_STATE_OF_THIS_JOB);
ClientJobState jobState = jobsMap.get(jobId);
ClientJobState jobStateCopy;
synchronized (jobState) {
try {
jobStateCopy = (ClientJobState) ProActiveMakeDeepCopy.WithProActiveObjectStream.makeDeepCopy(jobState);
} catch (Exception e) {
logger.error("Error when copying job state", e);
throw new IllegalStateException(e);
}
}
return jobStateCopy;
}
use of org.ow2.proactive.scheduler.common.exception.PermissionException in project scheduling by ow2-proactive.
the class SchedulerFrontendState method jobSubmitted.
synchronized void jobSubmitted(InternalJob job, UserIdentificationImpl ident) throws NotConnectedException, PermissionException, SubmissionClosedException, JobCreationException {
// put the job inside the frontend management list
jobs.put(job.getId(), new IdentifiedJob(job.getId(), ident, job.getGenericInformation()));
// increase number of submit for this user
ident.addSubmit();
// send update user event
usersUpdated(new NotificationData<UserIdentification>(SchedulerEvent.USERS_UPDATE, ident));
jlogger.info(job.getId(), "submitted: name '" + job.getName() + "', tasks '" + job.getTotalNumberOfTasks() + "', owner '" + job.getOwner() + "'");
try {
jlogger.info(job.getId(), job.display());
} catch (Exception e) {
jlogger.error(job.getId(), "Error while displaying the job :", e);
}
}
Aggregations