Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- method valid_task {
- shift;
- my $r_task = shift;
- return unless defined $r_task;
- my %h_task = %{$r_task};
- my %h_attrs;
- #--- Schedule tag
- if ( !defined $h_task{'schedule'} ) {
- $self->error_log->push('A "schedule" tag is required');
- return 0;
- }
- %h_attrs = %{ $h_task{'schedule'}[0] };
- my %h_schedule_id;
- foreach (keys %h_attrs) {
- if (/^id$/) {
- #--- Schedule id's must be unique
- if (defined $h_schedule_id{'id'}) {
- $self->error_log->push('Schedule id "'.$h_schedule_id{'id'}.'" is already defined');
- return 0;
- }
- $h_schedule_id{'id'}++;
- } elsif (/^time$/) {
- #--- A time attribute can have a list of time specifications
- my $s_time_spec = &Utils::trim( $h_attrs{'time'} );
- if ($s_time_spec eq '') {
- $self->error_log->push('Time specification empty');
- return 0;
- }
- my @a_time_list = split /$LIST_SEPARATOR/, $s_time_spec;
- foreach (@a_time_list) {
- if ( !&Utils::valid_time ($_) ) {
- print 'Time specification "'.$_.'" invalid';
- $self->error_log->push('Time specification "'.$_.'" invalid');
- return 0;
- }
- }
- } else {
- $self->error_log->push('Tag "'.$_.'" not recognized');
- return 0;
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement