job = getDelegate().selectJobDetail(conn,
newTrigger.getJobName(), newTrigger.getJobGroup(),
getClassLoadHelper());
}
if (job == null) {
throw new JobPersistenceException("The job ("
+ newTrigger.getFullJobName()
+ ") referenced by the trigger does not exist.");
}
if (job.isVolatile() && !newTrigger.isVolatile()) {
throw new JobPersistenceException(
"It does not make sense to "
+ "associate a non-volatile Trigger with a volatile Job!");
}
if (job.isStateful() && !recovering) {
state = checkBlockedState(conn, ctxt, job.getName(),
job.getGroup(), state);
}
if (existingTrigger) {
if (newTrigger instanceof SimpleTrigger && ((SimpleTrigger)newTrigger).hasAdditionalProperties() == false ) {
getDelegate().updateSimpleTrigger(conn,
(SimpleTrigger) newTrigger);
} else if (newTrigger instanceof CronTrigger && ((CronTrigger)newTrigger).hasAdditionalProperties() == false ) {
getDelegate().updateCronTrigger(conn,
(CronTrigger) newTrigger);
} else {
getDelegate().updateBlobTrigger(conn, newTrigger);
}
getDelegate().updateTrigger(conn, newTrigger, state, job);
} else {
getDelegate().insertTrigger(conn, newTrigger, state, job);
if (newTrigger instanceof SimpleTrigger && ((SimpleTrigger)newTrigger).hasAdditionalProperties() == false ) {
getDelegate().insertSimpleTrigger(conn,
(SimpleTrigger) newTrigger);
} else if (newTrigger instanceof CronTrigger && ((CronTrigger)newTrigger).hasAdditionalProperties() == false ) {
getDelegate().insertCronTrigger(conn,
(CronTrigger) newTrigger);
} else {
getDelegate().insertBlobTrigger(conn, newTrigger);
}
}
} catch (Exception e) {
throw new JobPersistenceException("Couldn't store trigger '" + newTrigger.getName() + "' for '"
+ newTrigger.getJobName() + "' job:" + e.getMessage(), e);
}
}