line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CatalystX::Eta::Controller::AutoObject; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1360
|
use Moose::Role; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
14
|
|
4
|
|
|
|
|
|
|
requires 'object'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
around object => \&AutoObject_around_object; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub AutoObject_around_object { |
9
|
7
|
|
|
7
|
|
81782
|
my $orig = shift; |
10
|
7
|
|
|
|
|
18
|
my $self = shift; |
11
|
7
|
|
|
|
|
36
|
my $config = $self->config; |
12
|
|
|
|
|
|
|
|
13
|
7
|
|
|
|
|
464
|
my ( $c, $id ) = @_; |
14
|
|
|
|
|
|
|
|
15
|
7
|
|
50
|
|
|
27
|
my $primary_column = $self->config->{primary_key_column} || 'id'; |
16
|
|
|
|
|
|
|
|
17
|
7
|
100
|
|
|
|
469
|
$config->{object_verify_type} = !defined $config->{object_verify_type} ? 'int' : $config->{object_verify_type}; |
18
|
|
|
|
|
|
|
|
19
|
7
|
50
|
|
|
|
34
|
unless ( $config->{object_verify_type} eq 'none' ) { |
20
|
|
|
|
|
|
|
|
21
|
7
|
50
|
|
|
|
31
|
if ( $config->{object_verify_type} eq 'int' ) { |
|
|
0
|
|
|
|
|
|
22
|
7
|
50
|
|
|
|
22
|
my $id_can_de_negative = $self->config->{id_can_de_negative} ? '-?' : ''; |
23
|
7
|
50
|
|
|
|
478
|
$self->status_bad_request( $c, message => 'invalid.int' ), $c->detach |
24
|
|
|
|
|
|
|
unless $id =~ /^$id_can_de_negative[0-9]+$/; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif ( $config->{object_verify_type} eq 'uuid4' ) { |
27
|
0
|
0
|
|
|
|
0
|
$self->status_bad_request( $c, message => 'invalid.uuid' ), $c->detach |
28
|
|
|
|
|
|
|
unless $id =~ /[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}/i; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else { |
31
|
|
|
|
|
|
|
$c->log->error( |
32
|
0
|
|
|
|
|
0
|
"CatalystX::Eta::Controller::AutoObject: unknown object_verify_type " . $config->{object_verify_type} ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
7
|
|
|
|
|
34
|
$c->stash->{object} = $c->stash->{collection}->search( { "me.$primary_column" => $id } ); |
38
|
7
|
|
|
|
|
3860
|
$c->stash->{ $config->{object_key} } = $c->stash->{object}->next; |
39
|
|
|
|
|
|
|
|
40
|
7
|
100
|
|
|
|
15781
|
$c->detach('/error_404') unless defined $c->stash->{ $config->{object_key} }; |
41
|
|
|
|
|
|
|
|
42
|
6
|
|
|
|
|
406
|
$self->$orig(@_); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |