line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Articulate::Service::List; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3214
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Articulate::Syntax; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
7
|
1
|
|
|
1
|
|
2048
|
use Articulate::Sortation::MetaDelver; |
|
1
|
|
|
|
|
29
|
|
|
1
|
|
|
|
|
38
|
|
8
|
|
|
|
|
|
|
# The following provide objects which must be created on a per-request basis |
9
|
1
|
|
|
1
|
|
8
|
use Articulate::Request; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
10
|
1
|
|
|
1
|
|
384
|
use Articulate::Response; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
363
|
use Moo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
13
|
|
|
|
|
|
|
with 'Articulate::Role::Service'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
454
|
use Try::Tiny; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
81
|
|
17
|
1
|
|
|
1
|
|
6
|
use Scalar::Util qw(blessed); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
418
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub handle_list { |
20
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
21
|
0
|
|
|
|
|
|
my $request = shift; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $location = loc $request->data->{location}; |
24
|
0
|
|
|
|
|
|
my $sort = $request->data->{sort}; # needs careful validation as this can do all sorts of fun constructor logic |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my $user = $request->user_id; |
27
|
0
|
|
|
|
|
|
my $permission = $self->authorisation->permitted ( $user, read => $location ); |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
if ( $permission ) { |
30
|
0
|
|
|
|
|
|
my $items = []; |
31
|
0
|
|
|
|
|
|
foreach my $item_location (map { loc "$location/$_" } $self->storage->list_items($location)) { |
|
0
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if ( $self->authorisation->permitted ( $user, read => $item_location ) ) { |
33
|
0
|
|
|
|
|
|
my $item = $self->construction->construct( { |
34
|
|
|
|
|
|
|
location => $item_location, |
35
|
|
|
|
|
|
|
meta => $self->storage->get_meta($item_location), |
36
|
|
|
|
|
|
|
content => $self->storage->get_content($item_location), |
37
|
|
|
|
|
|
|
} ); |
38
|
0
|
|
|
|
|
|
$self->augmentation->augment ($item); # this will throw if it fails |
39
|
0
|
|
|
|
|
|
push @$items, $item; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
|
my $sorter = Articulate::Sortation::MetaDelver->new( $sort ); |
43
|
0
|
|
|
|
|
|
return response 'list', { |
44
|
|
|
|
|
|
|
list => [ |
45
|
|
|
|
|
|
|
map { |
46
|
0
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
is => $_->location->[-2], |
48
|
|
|
|
|
|
|
location => $_->location, |
49
|
|
|
|
|
|
|
schema => $_->meta->{schema}, |
50
|
|
|
|
|
|
|
content => $_->content, |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
0
|
|
|
|
|
|
@{ $sorter->schwartz($items) } |
54
|
|
|
|
|
|
|
], |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else { |
58
|
0
|
|
|
|
|
|
throw_error 'Forbidden' => $permission->reason; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |