use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testPauseJobException.
@Test
public void testPauseJobException() throws SchedulerException {
Job job = mock(Job.class);
doReturn(job).when(schedulerService).getJob(anyString());
doReturn(true).when(schedulerService).isScheduleAllowed();
doThrow(new SchedulerException("pause-exception")).when(schedulerService.scheduler).pauseJob(anyString());
try {
schedulerService.pauseJob("job-id");
} catch (SchedulerException e) {
assertEquals("pause-exception", e.getMessage());
}
}
use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SolutionImportHandlerIT method testImportSchedules.
@Test
@SuppressWarnings("unchecked")
public void testImportSchedules() throws PlatformImportException, SchedulerException {
SolutionImportHandler importHandler = new SolutionImportHandler(Collections.emptyList());
importHandler = spy(importHandler);
List<JobScheduleRequest> requests = new ArrayList<JobScheduleRequest>(4);
requests.add(createJobScheduleRequest("NORMAL", JobState.NORMAL));
requests.add(createJobScheduleRequest("PAUSED", JobState.PAUSED));
requests.add(createJobScheduleRequest("PAUSED", JobState.COMPLETE));
requests.add(createJobScheduleRequest("PAUSED", JobState.ERROR));
doReturn(new ArrayList<Job>()).when(importHandler).getAllJobs(any());
importHandler.importSchedules(requests);
List<Job> jobs = scheduler.getJobs(new IJobFilter() {
@Override
public boolean accept(Job job) {
return true;
}
});
assertEquals(4, jobs.size());
for (Iterator<?> iterator = jobs.iterator(); iterator.hasNext(); ) {
Job job = (Job) iterator.next();
assertEquals(job.getJobName(), job.getState().toString());
}
}
use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SolutionImportHandlerIT method init.
@Before
public void init() throws PlatformInitializationException, SchedulerException {
MicroPlatform mp = new MicroPlatform();
mp.define("IScheduler", TestQuartzScheduler.class);
mp.define(IUserRoleListService.class, StubUserRoleListService.class);
IAuthorizationPolicy policy = mock(IAuthorizationPolicy.class);
when(policy.isAllowed(anyString())).thenReturn(true);
mp.defineInstance(IAuthorizationPolicy.class, policy);
mp.start();
scheduler = PentahoSystem.get(IScheduler.class);
scheduler.start();
}
use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SchedulerService method getJobInfo.
public Job getJobInfo(String jobId) throws SchedulerException {
Job job = getJob(jobId);
if (job == null) {
return null;
}
if (canAdminister() || getSession().getName().equals(job.getUserName())) {
for (String key : job.getJobParams().keySet()) {
Serializable value = job.getJobParams().get(key);
if (value != null && value.getClass() != null && value.getClass().isArray()) {
String[] sa = (new String[0]).getClass().cast(value);
ArrayList<String> list = new ArrayList<>();
for (int i = 0; i < sa.length; i++) {
list.add(sa[i]);
}
job.getJobParams().put(key, list);
}
}
return job;
} else {
throw new RuntimeException("Job not found or improper credentials for access");
}
}
use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SchedulerService method getContentCleanerJob.
public Job getContentCleanerJob() throws SchedulerException {
IPentahoSession session = getSession();
// this authentication wasn't matching with the job user name,
final String principalName = session.getName();
// changed to get name via the current session
final Boolean canAdminister = getPolicy().isAllowed(AdministerSecurityAction.NAME);
List<Job> jobs = getScheduler().getJobs(getJobFilter(canAdminister, principalName));
if (jobs.size() > 0) {
return jobs.get(0);
}
return null;
}
Aggregations