@Override
public void validate(Object object, Errors errors) {
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "task.groupName", "group.empty");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "task.name", "name.empty");
Task task = ((TaskDTO) object).getTask();
if (!StringUtils.isEmpty(task.getTimerSchedule())) {
// if there is a timer schedule, check it is valid for quartz cron trigger
try {
new CronExpression(task.getTimerSchedule());
} catch (ParseException e) {
errors.rejectValue("task.timerSchedule", "timer.schedule.invalid", e.getMessage());
}
}
if (task.getGroupName() != null && Constants.GROUP_NAME_ALL.equals(task.getGroupName().trim())) {
errors.rejectValue("task.groupName", "group.illegal", Constants.GROUP_NAME_ALL + " not allowed as group name");
}
}