}
// Add jobs
Iterator jobs = csConfig.getJobDefinitions().iterator();
while (jobs.hasNext()) {
JobDefinition job = (JobDefinition) jobs.next();
String jobName = db.getDbReference() + "." + job.getName();
try {
Task task = null;
if (job.getType() == JobDefinition.TYPE_TMLSCRIPTMODULE) {
ScriptTask scriptTask = new ScriptTask();
scriptTask.setCancelJobOnFail(true);
scriptTask.setDatabase(db.getDbReference());
scriptTask.setModule(job.getResource());
task = scriptTask;
}
else if (job.getType() == JobDefinition.TYPE_JAVA) {
JavaTask javaTask = new JavaTask();
javaTask.setClassName(job.getResource());
task = javaTask;
}
else {
getLog().error("Error adding job '" + jobName + "'. Unknown job type: " + job.getType());
continue;
}
task.setDescription(job.getDescription());
JobSchedule schedule = null;
if (job.getSchedule() != null && !job.getSchedule().trim().equals("")) {
schedule = new JobSchedule();
schedule.setEnabled(true);
schedule.setScheduleData(job.getSchedule());
schedule.setType(JobSchedule.TYPE_CRON);
}
Job schedulerJob = getScheduler().addCustomTaskJob(jobName, task, false, schedule);
schedulerJob.setDescription(job.getDescription());
schedulerJob.getOptions().put("database", db.getDbReference());
info.getEnforcedJobDefinitions().add(schedulerJob.getName());
}
catch (Exception e) {
getLog().error("Error adding job '" + jobName + "' from content store configuration", e);