QuartzScheduler implements IScheduler { @Override public void validateJobParams( Map<String, Serializable> jobParams ) throws SchedulerException { final Object streamProviderObj = jobParams.get( RESERVEDMAPKEY_STREAMPROVIDER ); if ( streamProviderObj instanceof String ) { String inputFilePath = null; final String inputOutputString = (String) streamProviderObj; final String[] tokens = inputOutputString.split( ":" ); if ( !ArrayUtils.isEmpty( tokens ) && tokens.length == 2 ) { inputFilePath = tokens[ 0 ].split( "=" )[ 1 ].trim(); if ( StringUtils.isNotBlank( inputFilePath ) ) { final IUnifiedRepository repository = PentahoSystem.get( IUnifiedRepository.class ); final RepositoryFile repositoryFile = repository.getFile( inputFilePath ); if ( ( repositoryFile == null ) || repositoryFile.isFolder() || !repositoryFile.isSchedulable() ) { throw new SchedulerException( Messages.getInstance().getString( "QuartzScheduler.ERROR_0008_SCHEDULING_IS_NOT_ALLOWED" ) ); } } } } } QuartzScheduler( SchedulerFactory schedulerFactory );  QuartzScheduler(); void setQuartzSchedulerFactory( SchedulerFactory quartzSchedulerFactory ); Scheduler getQuartzScheduler(); Job createJob( String jobName, String actionId, Map<String, Serializable> jobParams, IJobTrigger trigger ); Job createJob( String jobName, Class<? extends IAction> action, Map<String, Serializable> jobParams,
      IJobTrigger trigger ); Job createJob( String jobName, Class<? extends IAction> action, Map<String, Serializable> jobParams,
      IJobTrigger trigger, IBackgroundExecutionStreamProvider outputStreamProvider ); Job createJob( String jobName, String actionId, Map<String, Serializable> jobParams, IJobTrigger trigger,
      IBackgroundExecutionStreamProvider outputStreamProvider ); static Trigger createQuartzTrigger( IJobTrigger jobTrigger, QuartzJobKey jobId ); @Override void updateJob( String jobId, Map<String, Serializable> jobParams, IJobTrigger trigger ); Map<IScheduleSubject, ComplexJobTrigger> getAvailabilityWindows(); List<IJobResult> getJobHistory( String jobId ); void triggerNow( String jobId ); @SuppressWarnings( "unchecked" ) Job getJob( String jobId ); @SuppressWarnings( "unchecked" ) List<Job> getJobs( IJobFilter filter ); Integer getMinScheduleInterval( IScheduleSubject subject ); ComplexJobTrigger getSubjectAvailabilityWindow( IScheduleSubject subject ); void pause(); void pauseJob( String jobId ); void removeJob( String jobId ); void start(); void resumeJob( String jobId ); void setAvailabilityWindows( Map<IScheduleSubject, ComplexJobTrigger> availability ); void setMinScheduleInterval( IScheduleSubject subject, int intervalInSeconds ); void setSubjectAvailabilityWindow( IScheduleSubject subject, ComplexJobTrigger availability ); static ComplexJobTrigger createComplexTrigger( String cronExpression ); SchedulerStatus getStatus(); void shutdown(); static String prettyPrintMap( Map<String, Serializable> map ); void addListener( ISchedulerListener listener ); void setListeners( Collection<ISchedulerListener> listeners ); void fireJobCompleted( IAction actionBean, String actionUser, Map<String, Serializable> params,
      IBackgroundExecutionStreamProvider streamProvider ); @Override void validateJobParams( Map<String, Serializable> jobParams ); static final String RESERVEDMAPKEY_ACTIONCLASS; static final String RESERVEDMAPKEY_ACTIONUSER; static final String RESERVEDMAPKEY_ACTIONID; static final String RESERVEDMAPKEY_STREAMPROVIDER; static final String RESERVEDMAPKEY_STREAMPROVIDER_INPUTFILE; static final String RESERVEDMAPKEY_UIPASSPARAM; static final String RESERVEDMAPKEY_LINEAGE_ID; static final String RESERVEDMAPKEY_RESTART_FLAG; static final String RESERVEDMAPKEY_AUTO_CREATE_UNIQUE_FILENAME; static final String RESERVEDMAPKEY_APPEND_DATE_FORMAT; }
@Test public void testValidateParamsNoStreamProviderParam() throws SchedulerException { new QuartzScheduler().validateJobParams( Collections.emptyMap() ); }
@Test public void testValidateParamsNoStringConf() throws SchedulerException { new QuartzScheduler() .validateJobParams( Collections.singletonMap( QuartzScheduler.RESERVEDMAPKEY_STREAMPROVIDER, 1L ) ); }
@Test public void testValidateParamsNoInputFile() throws SchedulerException { new QuartzScheduler() .validateJobParams( Collections.singletonMap( QuartzScheduler.RESERVEDMAPKEY_STREAMPROVIDER, "someinputfile" ) ); }
@Test( expected = SchedulerException.class ) public void testValidateParamsFileNotFound() throws SchedulerException { new QuartzScheduler() .validateJobParams( Collections.singletonMap( QuartzScheduler.RESERVEDMAPKEY_STREAMPROVIDER, "input = /home/admin/notexist.ktr : output = /home/admin/notexist" ) ); }
@Test( expected = SchedulerException.class ) public void testValidateParamsFileIsFolder() throws SchedulerException { new QuartzScheduler() .validateJobParams( Collections.singletonMap( QuartzScheduler.RESERVEDMAPKEY_STREAMPROVIDER, "input = /home/admin : output = /home/admin/notexist" ) ); }
@Test( expected = SchedulerException.class ) public void testValidateParamsSchedulingNotAllowed() throws SchedulerException { new QuartzScheduler() .validateJobParams( Collections.singletonMap( QuartzScheduler.RESERVEDMAPKEY_STREAMPROVIDER, "input = /home/admin/notallowed.ktr : output = /home/admin/notallowed" ) ); }
@Test public void testValidateParamsSchedulingAllowed() throws SchedulerException { new QuartzScheduler() .validateJobParams( Collections.singletonMap( QuartzScheduler.RESERVEDMAPKEY_STREAMPROVIDER, "input = /home/admin/allowed.ktr : output = /home/admin/allowed." ) ); }