Search in sources :

Example 86 with SchedulerException

use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.

the class RepositoryCleanerSystemListener method scheduleJob.

private void scheduleJob(IScheduler scheduler) throws SchedulerException {
    JobTrigger trigger = findJobTrigger();
    if (trigger != null) {
        logger.info("Creating new job with trigger: " + trigger);
        scheduler.createJob(RepositoryGcJob.JOB_NAME, RepositoryGcJob.class, null, trigger);
    }
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) JobTrigger(org.pentaho.platform.api.scheduler2.JobTrigger) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger)

Example 87 with SchedulerException

use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.

the class DefaultSchedulerService method getJobs.

/**
 * {@inheritDoc}
 */
public Job[] getJobs() throws SchedulerException {
    // $NON-NLS-1$
    IScheduler scheduler = PentahoSystem.get(IScheduler.class, "IScheduler2", null);
    IPentahoSession session = PentahoSessionHolder.getSession();
    String principalName = session.getName();
    Boolean canAdminister = PentahoSystem.get(IAuthorizationPolicy.class).isAllowed(ADMIN_PERM);
    return scheduler.getJobs(job -> {
        if (canAdminister) {
            return !IBlockoutManager.BLOCK_OUT_JOB_NAME.equals(job.getJobName());
        }
        return principalName.equals(job.getUserName());
    }).toArray(new Job[0]);
}
Also used : WebService(javax.jws.WebService) IBlockoutManager(org.pentaho.platform.api.scheduler2.IBlockoutManager) IScheduler(org.pentaho.platform.api.scheduler2.IScheduler) HashMap(java.util.HashMap) SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) PentahoSystem(org.pentaho.platform.engine.core.system.PentahoSystem) PentahoSessionHolder(org.pentaho.platform.engine.core.system.PentahoSessionHolder) Serializable(java.io.Serializable) SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) JobTrigger(org.pentaho.platform.api.scheduler2.JobTrigger) IAuthorizationPolicy(org.pentaho.platform.api.engine.IAuthorizationPolicy) Map(java.util.Map) Log(org.apache.commons.logging.Log) Job(org.pentaho.platform.api.scheduler2.Job) LogFactory(org.apache.commons.logging.LogFactory) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) IAuthorizationPolicy(org.pentaho.platform.api.engine.IAuthorizationPolicy) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) IScheduler(org.pentaho.platform.api.scheduler2.IScheduler)

Example 88 with SchedulerException

use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.

the class DefaultSchedulerService method pause.

/**
 * {@inheritDoc}
 */
public void pause() throws SchedulerException {
    // $NON-NLS-1$
    IScheduler scheduler = PentahoSystem.get(IScheduler.class, "IScheduler2", null);
    scheduler.pause();
}
Also used : IScheduler(org.pentaho.platform.api.scheduler2.IScheduler)

Example 89 with SchedulerException

use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.

the class DefaultSchedulerService method pauseJob.

/**
 * {@inheritDoc}
 */
public void pauseJob(String jobId) throws SchedulerException {
    // $NON-NLS-1$
    IScheduler scheduler = PentahoSystem.get(IScheduler.class, "IScheduler2", null);
    scheduler.pauseJob(jobId);
}
Also used : IScheduler(org.pentaho.platform.api.scheduler2.IScheduler)

Example 90 with SchedulerException

use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.

the class DefaultSchedulerService method createJob.

private String createJob(String jobName, Map<String, ParamValue> jobParams, JobTrigger trigger) throws SchedulerException {
    // $NON-NLS-1$
    logger.debug("Creating job with schedule " + trigger.toString());
    Job job = null;
    try {
        // $NON-NLS-1$
        IScheduler scheduler = PentahoSystem.get(IScheduler.class, "IScheduler2", null);
        Map<String, Serializable> properJobParams = toProperMap(jobParams);
        scheduler.validateJobParams(properJobParams);
        job = scheduler.createJob(jobName, getDefaultActionId(), properJobParams, trigger);
    } catch (SchedulerException e) {
        // temporary error logging.. this needs to become an aspect
        logger.error(e.getMessage(), e);
        throw e;
    }
    return job.getJobId();
}
Also used : Serializable(java.io.Serializable) SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Job(org.pentaho.platform.api.scheduler2.Job) IScheduler(org.pentaho.platform.api.scheduler2.IScheduler)

Aggregations

SchedulerException (org.pentaho.platform.api.scheduler2.SchedulerException)51 Test (org.junit.Test)49 Job (org.pentaho.platform.api.scheduler2.Job)43 IScheduler (org.pentaho.platform.api.scheduler2.IScheduler)23 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)18 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)16 Serializable (java.io.Serializable)15 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)11 Date (java.util.Date)10 JobTrigger (org.pentaho.platform.api.scheduler2.JobTrigger)9 Scheduler (org.quartz.Scheduler)9 ArrayList (java.util.ArrayList)8 IJobFilter (org.pentaho.platform.api.scheduler2.IJobFilter)8 IOException (java.io.IOException)6 Calendar (java.util.Calendar)6 HashMap (java.util.HashMap)6 CronTrigger (org.quartz.CronTrigger)6 SimpleTrigger (org.quartz.SimpleTrigger)6 Trigger (org.quartz.Trigger)6 Response (javax.ws.rs.core.Response)5