@Override
public void storeTrigger(SchedulingContext ctxt, Trigger newTrigger,
boolean replaceExisting) throws JobPersistenceException {
log.debug("Storing Trigger: " + newTrigger.getFullName());
ReplaceableItem item = null;
try {
List<ReplaceableAttribute> attributes = new ArrayList<ReplaceableAttribute>();
attributes.add(new ReplaceableAttribute(TRIGGER_CLASS, newTrigger
.getClass().getName(), true));
attributes.add(new ReplaceableAttribute(TRIGGER_NAME, newTrigger
.getName(), true));
if (newTrigger.getCalendarName() != null) {
attributes.add(new ReplaceableAttribute(TRIGGER_CALENDAR_NAME,
newTrigger.getCalendarName(), true));
}
attributes.add(new ReplaceableAttribute(TRIGGER_GROUP, newTrigger
.getGroup(), true));
attributes.add(new ReplaceableAttribute(TRIGGER_JOB_GROUP,
newTrigger.getJobGroup(), true));
attributes.add(new ReplaceableAttribute(TRIGGER_JOB_NAME,
newTrigger.getJobName(), true));
attributes.add(new ReplaceableAttribute(TRIGGER_PRIORITY, String
.valueOf(newTrigger.getPriority()), true));
if (newTrigger.getEndTime() != null) {
attributes.add(new ReplaceableAttribute(TRIGGER_END_TIME,
dateFormat.format(newTrigger.getEndTime()), true));
}
if (newTrigger.getStartTime() != null) {
attributes.add(new ReplaceableAttribute(TRIGGER_START_TIME,
dateFormat.format(newTrigger.getStartTime()), true));
}
if (newTrigger.getNextFireTime() != null) {
attributes.add(new ReplaceableAttribute(TRIGGER_NEXT_FIRE_TIME,
dateFormat.format(newTrigger.getNextFireTime()), true));
}
item = new ReplaceableItem(
TriggerWrapper.getTriggerNameKey(newTrigger), attributes);
String json = mapper.writeValueAsString(newTrigger);
attributes.add(new ReplaceableAttribute(TRIGGER_JSON_LENGTH, String
.valueOf(json.length()), true));