make creating new job as cron is blank

This commit is contained in:
Kaoru FUZITA 2015-11-30 14:01:47 +09:00
parent 8b50c614c3
commit 1384e0130e
3 changed files with 11 additions and 10 deletions

View file

@ -125,6 +125,7 @@ public class AdminSchedulerAction extends FessAdminAction {
scheduledJobForm.jobLogging = Constants.ON;
scheduledJobForm.crawler = Constants.ON;
scheduledJobForm.available = Constants.ON;
scheduledJobForm.cronExpression = null;
scheduledJobForm.name =
ComponentUtil.getMessageManager().getMessage(LaRequestUtil.getRequest().getLocale(),
"labels." + type + "_job_title", name);

View file

@ -45,7 +45,6 @@ public class CreateForm implements Serializable {
@Size(max = 100)
public String target;
@Required
@Size(max = 100)
@CronExpression
public String cronExpression;

View file

@ -120,17 +120,18 @@ public class JobScheduler {
jobDataMap.put(Constants.JOB_EXECUTOR_TYPE, scriptType);
final JobDetail jobDetail = newJob(jobClass).withIdentity(jobId).usingJobData(jobDataMap).build();
final Trigger trigger =
newTrigger().withIdentity(triggerId).withSchedule(cronSchedule(scheduledJob.getCronExpression())).startNow().build();
if (StringUtil.isNotBlank(scheduledJob.getCronExpression())) {
final Trigger trigger =
newTrigger().withIdentity(triggerId).withSchedule(cronSchedule(scheduledJob.getCronExpression())).startNow().build();
try {
scheduler.scheduleJob(jobDetail, trigger);
} catch (final SchedulerException e) {
throw new ScheduledJobException("Failed to add Job: " + scheduledJob, e);
try {
scheduler.scheduleJob(jobDetail, trigger);
} catch (final SchedulerException e) {
throw new ScheduledJobException("Failed to add Job: " + scheduledJob, e);
}
logger.info("Starting Job " + scheduledJob.getId() + ":" + scheduledJob.getName());
}
logger.info("Starting Job " + scheduledJob.getId() + ":" + scheduledJob.getName());
}
public void unregister(final ScheduledJob scheduledJob) {