Search in sources :

Example 1 with RangerValidityRecurrence

use of org.apache.ranger.plugin.model.RangerValidityRecurrence in project ranger by apache.

the class RangerValidityScheduleValidator method validateTimeRangeSpec.

private boolean validateTimeRangeSpec(List<ValidationFailureDetails> validationFailures) {
    boolean ret;
    if (startTime.getTime() >= endTime.getTime()) {
        validationFailures.add(new ValidationFailureDetails(0, "startTime", "", false, true, false, "endTime is not later than startTime"));
        ret = false;
    } else {
        ret = true;
    }
    ret = validateTimeZone(validitySchedule.getTimeZone(), validationFailures) && ret;
    for (RangerValidityRecurrence recurrence : validitySchedule.getRecurrences()) {
        ret = validateValidityInterval(recurrence, validationFailures) && ret;
        if (ret) {
            ret = validateFieldSpec(recurrence, RangerValidityRecurrence.RecurrenceSchedule.ScheduleFieldSpec.minute, validationFailures) && ret;
            ret = validateFieldSpec(recurrence, RangerValidityRecurrence.RecurrenceSchedule.ScheduleFieldSpec.hour, validationFailures) && ret;
            ret = validateFieldSpec(recurrence, RangerValidityRecurrence.RecurrenceSchedule.ScheduleFieldSpec.dayOfMonth, validationFailures) && ret;
            ret = validateFieldSpec(recurrence, RangerValidityRecurrence.RecurrenceSchedule.ScheduleFieldSpec.dayOfWeek, validationFailures) && ret;
            ret = validateFieldSpec(recurrence, RangerValidityRecurrence.RecurrenceSchedule.ScheduleFieldSpec.month, validationFailures) && ret;
            ret = validateFieldSpec(recurrence, RangerValidityRecurrence.RecurrenceSchedule.ScheduleFieldSpec.year, validationFailures) && ret;
            ret = ret && validateIntervalDuration(recurrence, validationFailures);
            if (ret) {
                RangerValidityRecurrence.RecurrenceSchedule schedule = new RangerValidityRecurrence.RecurrenceSchedule(getNormalizedValue(recurrence, RangerValidityRecurrence.RecurrenceSchedule.ScheduleFieldSpec.minute), getNormalizedValue(recurrence, RangerValidityRecurrence.RecurrenceSchedule.ScheduleFieldSpec.hour), getNormalizedValue(recurrence, RangerValidityRecurrence.RecurrenceSchedule.ScheduleFieldSpec.dayOfMonth), getNormalizedValue(recurrence, RangerValidityRecurrence.RecurrenceSchedule.ScheduleFieldSpec.dayOfWeek), getNormalizedValue(recurrence, RangerValidityRecurrence.RecurrenceSchedule.ScheduleFieldSpec.month), getNormalizedValue(recurrence, RangerValidityRecurrence.RecurrenceSchedule.ScheduleFieldSpec.year));
                RangerValidityRecurrence normalizedRecurrence = new RangerValidityRecurrence(schedule, recurrence.getInterval());
                normalizedValiditySchedule.getRecurrences().add(normalizedRecurrence);
            }
        }
    }
    return ret;
}
Also used : RangerValidityRecurrence(org.apache.ranger.plugin.model.RangerValidityRecurrence) RecurrenceSchedule(org.apache.ranger.plugin.model.RangerValidityRecurrence.RecurrenceSchedule) RecurrenceSchedule(org.apache.ranger.plugin.model.RangerValidityRecurrence.RecurrenceSchedule)

Aggregations

RangerValidityRecurrence (org.apache.ranger.plugin.model.RangerValidityRecurrence)1 RecurrenceSchedule (org.apache.ranger.plugin.model.RangerValidityRecurrence.RecurrenceSchedule)1