App-Oozie
view release on metacpan or search on metacpan
lib/App/Oozie/Deploy/Validate/Spec/Coordinator.pm view on Meta::CPAN
package App::Oozie::Deploy::Validate::Spec::Coordinator;
use 5.014;
use strict;
use warnings;
our $VERSION = '0.020'; # VERSION
use namespace::autoclean -except => [qw/_options_data _options_config/];
use Moo;
use MooX::Options;
use List::MoreUtils qw( uniq );
use App::Oozie::Types::Common qw( IsFile );
use App::Oozie::Constants qw( EMPTY_STRING );
with qw(
App::Oozie::Role::Log
App::Oozie::Role::Fields::Generic
App::Oozie::Role::Validate::XML
);
sub verify {
my $self = shift;
my $xml_in = shift;
my($validation_errors, $total_errors);
my $looper;
$looper = sub {
my $hash = shift;
my $non_utc = shift;
my $wrong_parameters = shift;
foreach my $key ( keys %{ $hash } ) {
$non_utc->( $hash, $key );
$wrong_parameters->( $hash, $key );
my $value = $hash->{ $key };
$looper->( $value, $non_utc, $wrong_parameters ) if ref $value eq 'HASH';
}
return;
};
my @non_utc_tz;
my @restricted_properties;
my @restricted_keys = qw/startTime endTime/;
my %blacklist;
@blacklist{@restricted_keys} = ();
$looper->(
$xml_in,
sub {
my($h, $key) = @_;
return if $key ne 'timezone' || uc( $h->{$key} ) eq 'UTC';
push @non_utc_tz, $h->{$key};
return;
},
sub {
my($h, $key) = @_;
return if $key ne 'property';
$self->validate_xml_property(
\$validation_errors,
\$total_errors,
$h->{property},
);
for my $property ( @{ $h->{property} } ) {
my $property_name = defined($property->{name})? $property->{name} : EMPTY_STRING;
#if ($property_name eq 'startDate' || $property_name eq 'endDate') {
if (exists $blacklist{$property_name}) {
( run in 0.633 second using v1.01-cache-2.11-cpan-ceb78f64989 )