String month, day, hour, min;
String timerInterval = parametreManager.getProperty(Constante.IMPORT_TIMER_INTERVAL);
if (timerInterval == null && enabled) {
utx.rollback();
throw new EvasionException("Timer interval not define.");
}
//stop possible timer précédent.
Timer timer = getImportTimer();
if (timer != null) {
timer.cancel();
}
if (enabled) {
String[] param = parametreManager.getProperty(Constante.IMPORT_TIMER_INTERVAL).split("\\|");
month = param[0];
day = param[1];
hour = param[2];
min = param[3];
LOGGER.debug("Geoloc import Timer is : {} with timer {}", enabled, param);
try {
//start timer
timer = timerService.createCalendarTimer(
new ScheduleExpression().month(month).dayOfMonth(day).hour(hour).minute(min),
new TimerConfig(Constante.IMPORT_TIMER_NAME, false));
LOGGER.info("Last geoloc import: {}", timer.getNextTimeout());
} catch (IllegalArgumentException ex) {
LOGGER.error("Illegal argument exception on " + Constante.IMPORT_TIMER_INTERVAL + " parameter", ex);
utx.rollback();
}
}
utx.commit();
} catch (Exception ex) {
throw new EvasionException("Fail update import Geoloc Data.", ex);
}
}