use of org.quartz.SchedulerException in project opennms by OpenNMS.
the class ImportJobFactory method newJob.
/**
* {@inheritDoc}
*/
@Override
public Job newJob(final TriggerFiredBundle bundle, final Scheduler scheduler) throws SchedulerException {
JobDetail jobDetail = bundle.getJobDetail();
Class<ImportJob> jobClass = getJobClass(jobDetail);
ImportJob job = null;
try {
job = jobClass.newInstance();
job.setProvisioner(getProvisioner());
return job;
} catch (Throwable e) {
SchedulerException se = new SchedulerException("failed to create job class: " + jobDetail.getJobClass().getName() + "; " + e.getLocalizedMessage(), e);
throw se;
}
}
use of org.quartz.SchedulerException in project opennms by OpenNMS.
the class ImportScheduler method buildImportSchedule.
/**
* <p>buildImportSchedule</p>
*/
protected void buildImportSchedule() {
synchronized (m_lock) {
Iterator<RequisitionDef> it = m_configDao.getDefs().iterator();
while (it.hasNext()) {
RequisitionDef def = it.next();
JobDetail detail = null;
CronTriggerImpl trigger = null;
try {
detail = new JobDetailImpl(def.getImportName().orElse(null), JOB_GROUP, ImportJob.class, false, false);
detail.getJobDataMap().put(ImportJob.URL, def.getImportUrlResource().orElse(null));
detail.getJobDataMap().put(ImportJob.RESCAN_EXISTING, def.getRescanExisting());
trigger = new CronTriggerImpl(def.getImportName().orElse(null), JOB_GROUP, def.getCronSchedule().orElse(null));
trigger.setMisfireInstruction(CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING);
getScheduler().scheduleJob(detail, trigger);
} catch (ParseException e) {
LOG.error("buildImportSchedule: {}", e.getLocalizedMessage(), e);
} catch (SchedulerException e) {
LOG.error("buildImportSchedule: {}", e.getLocalizedMessage(), e);
}
}
}
printCurrentSchedule();
}
use of org.quartz.SchedulerException in project opennms by OpenNMS.
the class ImportScheduler method removeCurrentJobsFromSchedule.
/**
* Iterates of current job list and removes each job from the underlying schedule
*
* @throws org.quartz.SchedulerException if any.
*/
protected void removeCurrentJobsFromSchedule() throws SchedulerException {
printCurrentSchedule();
synchronized (m_lock) {
for (JobKey key : m_scheduler.getJobKeys(GroupMatcher.<JobKey>groupEquals(JOB_GROUP))) {
String jobName = key.getName();
try {
getScheduler().deleteJob(new JobKey(jobName, JOB_GROUP));
} catch (SchedulerException e) {
LOG.error("removeCurrentJobsFromSchedule: {}", e.getLocalizedMessage(), e);
}
}
}
printCurrentSchedule();
}
use of org.quartz.SchedulerException in project opennms by OpenNMS.
the class ReportJobFactory method newJob.
/**
* {@inheritDoc}
*/
@Override
public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException {
JobDetail jobDetail = bundle.getJobDetail();
Class<ReportJob> jobClass = getJobClass(jobDetail);
ReportJob job = null;
try {
job = jobClass.newInstance();
job.setReportd(getReportd());
return job;
} catch (Throwable e) {
SchedulerException se = new SchedulerException("failed to create job class: " + jobDetail.getJobClass().getName() + "; " + e.getLocalizedMessage(), e);
throw se;
}
}
use of org.quartz.SchedulerException in project opennms by OpenNMS.
the class DefaultSchedulerService method execute.
/*
* (non-Javadoc)
* @see
* org.opennms.web.svclayer.support.SchedulerService#execute(org.opennms
* .web.report.database.model.DatabaseReportCriteria, java.lang.String,
* org.springframework.webflow.execution.RequestContext)
*/
/**
* {@inheritDoc}
*/
@Override
public String execute(String id, ReportParameters criteria, DeliveryOptions deliveryOptions, RequestContext context) {
try {
if (m_reportWrapperService.validate(criteria, id) == false) {
context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(PARAMETER_ERROR).build());
return ERROR;
} else {
SimpleTriggerImpl trigger = new SimpleTriggerImpl(deliveryOptions.getInstanceId(), m_triggerGroup, new Date(), null, 0, 0L);
trigger.setJobName(m_jobDetail.getKey().getName());
trigger.getJobDataMap().put("criteria", (ReportParameters) criteria);
trigger.getJobDataMap().put("reportId", id);
trigger.getJobDataMap().put("mode", ReportMode.IMMEDIATE);
trigger.getJobDataMap().put("deliveryOptions", (DeliveryOptions) deliveryOptions);
try {
m_scheduler.scheduleJob(trigger);
} catch (SchedulerException e) {
LOG.warn(SCHEDULER_ERROR, e);
context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(SCHEDULER_ERROR).build());
return ERROR;
}
return SUCCESS;
}
} catch (ReportServiceLocatorException e) {
LOG.error(REPORTID_ERROR, e);
context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(REPORTID_ERROR).build());
return ERROR;
}
}
Aggregations