Search in sources :

Example 1 with ServerInfoService

use of com.haulmont.cuba.core.app.ServerInfoService in project cuba by cuba-platform.

the class CronValidator method validate.

@Override
public void validate(Object value) throws ValidationException {
    if (value != null) {
        ServerInfoService serverInfoService = AppBeans.get(ServerInfoService.NAME);
        Messages messages = AppBeans.get(Messages.NAME);
        try {
            new CronSequenceGenerator(value.toString(), serverInfoService.getTimeZone());
        } catch (Exception e) {
            throw new ValidationException(messages.getMessage(CronValidator.class, "validation.cronInvalid"));
        }
    }
}
Also used : ServerInfoService(com.haulmont.cuba.core.app.ServerInfoService) Messages(com.haulmont.cuba.core.global.Messages) ValidationException(com.haulmont.cuba.gui.components.ValidationException) CronSequenceGenerator(org.springframework.scheduling.support.CronSequenceGenerator) ValidationException(com.haulmont.cuba.gui.components.ValidationException)

Aggregations

ServerInfoService (com.haulmont.cuba.core.app.ServerInfoService)1 Messages (com.haulmont.cuba.core.global.Messages)1 ValidationException (com.haulmont.cuba.gui.components.ValidationException)1 CronSequenceGenerator (org.springframework.scheduling.support.CronSequenceGenerator)1