line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Sakai::Nakamura::ContentUtil; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
29626
|
use 5.008001; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
81
|
|
6
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
91
|
|
7
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
60
|
|
8
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
210
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
22
|
use base qw(Exporter); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1377
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT_OK = (); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#{{{sub add_file_metadata_setup |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub add_file_metadata_setup { |
21
|
5
|
|
|
5
|
1
|
235
|
my ( $base_url, $content_path, $content_filename, $content_fileextension ) = |
22
|
|
|
|
|
|
|
@_; |
23
|
5
|
100
|
|
|
|
14
|
if ( !defined $base_url ) { croak 'No base url defined to add against!'; } |
|
1
|
|
|
|
|
28
|
|
24
|
4
|
100
|
|
|
|
14
|
if ( !defined $content_path ) { |
25
|
1
|
|
|
|
|
11
|
croak 'No content path to add file meta data to!'; |
26
|
|
|
|
|
|
|
} |
27
|
3
|
100
|
|
|
|
12
|
if ( !defined $content_filename ) { |
28
|
1
|
|
|
|
|
10
|
croak 'No content filename provided when attempting to add meta data!'; |
29
|
|
|
|
|
|
|
} |
30
|
2
|
100
|
|
|
|
7
|
if ( !defined $content_fileextension ) { |
31
|
1
|
|
|
|
|
12
|
croak |
32
|
|
|
|
|
|
|
'No content file extension provided when attempting to add meta data!'; |
33
|
|
|
|
|
|
|
} |
34
|
1
|
|
|
|
|
7
|
my $post_variables = |
35
|
|
|
|
|
|
|
"\$post_variables = ['requests','[{\"url\":\"$content_path\",\"method\":\"POST\",\"parameters\":{\"sakai:pooled-content-file-name\":\"$content_filename\",\"sakai:description\":\"\",\"sakai:permissions\":\"public\",\"sakai:copyright\":\"creativecommons\",\"sakai:allowcomments\":\"true\",\"sakai:showcomments\":\"true\",\"sakai:fileextension\":\"$content_fileextension\",\"_charset_\":\"utf-8\"},\"_charset_\":\"utf-8\"},{\"url\":\"$content_path.save.json\",\"method\":\"POST\",\"_charset_\":\"utf-8\"}]']"; |
36
|
1
|
|
|
|
|
11
|
return "post $base_url/system/batch $post_variables"; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#}}} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#{{{sub add_file_metadata_eval |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub add_file_metadata_eval { |
44
|
1
|
|
|
1
|
1
|
2
|
my ($res) = @_; |
45
|
1
|
|
|
|
|
3
|
return ( ${$res}->code eq '200' ); |
|
1
|
|
|
|
|
8
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
#}}} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#{{{sub add_file_perms_setup |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub add_file_perms_setup { |
53
|
3
|
|
|
3
|
1
|
51
|
my ( $base_url, $content_path ) = @_; |
54
|
3
|
100
|
|
|
|
9
|
if ( !defined $base_url ) { croak 'No base url defined to add against!'; } |
|
1
|
|
|
|
|
9
|
|
55
|
2
|
100
|
|
|
|
7
|
if ( !defined $content_path ) { |
56
|
1
|
|
|
|
|
11
|
croak 'No content path to add file perms to!'; |
57
|
|
|
|
|
|
|
} |
58
|
1
|
|
|
|
|
8
|
my $post_variables = |
59
|
|
|
|
|
|
|
"\$post_variables = ['requests','[{\"url\":\"$content_path.members.html\",\"method\":\"POST\",\"parameters\":{\":viewer\":[\"everyone\",\"anonymous\"]}},{\"url\":\"$content_path.modifyAce.html\",\"method\":\"POST\",\"parameters\":{\"principalId\":[\"everyone\"],\"privilege\@jcr:read\":\"granted\"}},{\"url\":\"$content_path.modifyAce.html\",\"method\":\"POST\",\"parameters\":{\"principalId\":[\"anonymous\"],\"privilege\@jcr:read\":\"granted\"}}]']"; |
60
|
1
|
|
|
|
|
9
|
return "post $base_url/system/batch $post_variables"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#}}} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#{{{sub add_file_perms_eval |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub add_file_perms_eval { |
68
|
1
|
|
|
1
|
1
|
489
|
my ($res) = @_; |
69
|
1
|
|
|
|
|
2
|
return ( ${$res}->code eq '200' ); |
|
1
|
|
|
|
|
4
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#}}} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#{{{sub comment_add_setup |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub comment_add_setup { |
77
|
0
|
|
|
0
|
0
|
|
my ( $base_url, $content_path, $comment ) = @_; |
78
|
0
|
0
|
|
|
|
|
if ( !defined $base_url ) { croak 'No base url defined to add against!'; } |
|
0
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
if ( !defined $content_path ) { |
80
|
0
|
|
|
|
|
|
croak 'No content path to add comments to!'; |
81
|
|
|
|
|
|
|
} |
82
|
0
|
0
|
|
|
|
|
if ( !defined $comment ) { |
83
|
0
|
|
|
|
|
|
croak 'No comment provided to add!'; |
84
|
|
|
|
|
|
|
} |
85
|
0
|
|
|
|
|
|
my $post_variables = "\$post_variables = ['comment','$comment']"; |
86
|
0
|
|
|
|
|
|
return "post $base_url/$content_path.comments $post_variables"; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
#}}} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#{{{sub comment_add_eval |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub comment_add_eval { |
94
|
0
|
|
|
0
|
0
|
|
my ($res) = @_; |
95
|
0
|
|
|
|
|
|
return ( ${$res}->code eq '201' ); |
|
0
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
#}}} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |