line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Apache::Sling::ContentUtil; |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
40792
|
use 5.008001; |
|
5
|
|
|
|
|
22
|
|
|
5
|
|
|
|
|
210
|
|
6
|
5
|
|
|
5
|
|
31
|
use strict; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
226
|
|
7
|
5
|
|
|
5
|
|
28
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
184
|
|
8
|
5
|
|
|
5
|
|
27
|
use Carp; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
371
|
|
9
|
5
|
|
|
5
|
|
561
|
use Apache::Sling::URL; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
235
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require Exporter; |
12
|
|
|
|
|
|
|
|
13
|
5
|
|
|
5
|
|
28
|
use base qw(Exporter); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
7643
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT_OK = (); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.27'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#{{{sub add_setup |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub add_setup { |
22
|
5
|
|
|
5
|
1
|
139
|
my ( $base_url, $remote_dest, $properties ) = @_; |
23
|
5
|
100
|
|
|
|
21
|
if ( !defined $base_url ) { croak 'No base URL provided!'; } |
|
1
|
|
|
|
|
40
|
|
24
|
4
|
100
|
|
|
|
12
|
if ( !defined $remote_dest ) { |
25
|
2
|
|
|
|
|
26
|
croak 'No position or ID to perform action for specified!'; |
26
|
|
|
|
|
|
|
} |
27
|
2
|
|
|
|
|
8
|
my $property_post_vars = |
28
|
|
|
|
|
|
|
Apache::Sling::URL::properties_array_to_string($properties); |
29
|
2
|
|
|
|
|
5
|
my $post_variables = "\$post_variables = [$property_post_vars]"; |
30
|
2
|
|
|
|
|
15
|
return "post $base_url/$remote_dest $post_variables"; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#}}} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#{{{sub add_eval |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub add_eval { |
38
|
1
|
|
|
1
|
1
|
2
|
my ($res) = @_; |
39
|
1
|
|
|
|
|
2
|
return ( ${$res}->code =~ /^20(0|1)$/msx ); |
|
1
|
|
|
|
|
5
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#}}} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#{{{sub copy_setup |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub copy_setup { |
47
|
6
|
|
|
6
|
1
|
393
|
my ( $base_url, $remote_src, $remote_dest, $replace ) = @_; |
48
|
6
|
100
|
|
|
|
17
|
if ( !defined $base_url ) { croak 'No base url defined!'; } |
|
1
|
|
|
|
|
8
|
|
49
|
5
|
100
|
|
|
|
11
|
if ( !defined $remote_src ) { |
50
|
2
|
|
|
|
|
20
|
croak 'No content source to copy from defined!'; |
51
|
|
|
|
|
|
|
} |
52
|
3
|
100
|
|
|
|
6
|
if ( !defined $remote_dest ) { |
53
|
1
|
|
|
|
|
8
|
croak 'No content destination to copy to defined!'; |
54
|
|
|
|
|
|
|
} |
55
|
2
|
|
|
|
|
5
|
my $post_variables = |
56
|
|
|
|
|
|
|
"\$post_variables = [':dest','$remote_dest',':operation','copy'"; |
57
|
2
|
100
|
|
|
|
5
|
$post_variables .= ( defined $replace ? q{,':replace','true'} : q{} ); |
58
|
2
|
|
|
|
|
2
|
$post_variables .= ']'; |
59
|
2
|
|
|
|
|
12
|
return "post $base_url/$remote_src $post_variables"; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
#}}} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#{{{sub copy_eval |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub copy_eval { |
67
|
1
|
|
|
1
|
1
|
2
|
my ($res) = @_; |
68
|
1
|
|
|
|
|
2
|
return ( ${$res}->code =~ /^20(0|1)$/msx ); |
|
1
|
|
|
|
|
4
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#}}} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
#{{{sub delete_setup |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub delete_setup { |
76
|
4
|
|
|
4
|
1
|
408
|
my ( $base_url, $remote_dest ) = @_; |
77
|
4
|
100
|
|
|
|
13
|
if ( !defined $base_url ) { croak 'No base url defined!'; } |
|
1
|
|
|
|
|
9
|
|
78
|
3
|
100
|
|
|
|
9
|
if ( !defined $remote_dest ) { |
79
|
2
|
|
|
|
|
21
|
croak 'No content destination to delete defined!'; |
80
|
|
|
|
|
|
|
} |
81
|
1
|
|
|
|
|
2
|
my $post_variables = q{$post_variables = [':operation','delete']}; |
82
|
1
|
|
|
|
|
5
|
return "post $base_url/$remote_dest $post_variables"; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
#}}} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
#{{{sub delete_eval |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub delete_eval { |
90
|
1
|
|
|
1
|
1
|
1
|
my ($res) = @_; |
91
|
1
|
|
|
|
|
2
|
return ( ${$res}->code eq '200' ); |
|
1
|
|
|
|
|
4
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
#}}} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#{{{sub exists_setup |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub exists_setup { |
99
|
5
|
|
|
5
|
1
|
377
|
my ( $base_url, $remote_dest ) = @_; |
100
|
5
|
100
|
|
|
|
16
|
if ( !defined $base_url ) { croak 'No base url defined!'; } |
|
1
|
|
|
|
|
8
|
|
101
|
4
|
100
|
|
|
|
13
|
if ( !defined $remote_dest ) { |
102
|
3
|
|
|
|
|
36
|
croak 'No position or ID to perform exists for specified!'; |
103
|
|
|
|
|
|
|
} |
104
|
1
|
|
|
|
|
6
|
return "get $base_url/$remote_dest.json"; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
#}}} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
#{{{sub exists_eval |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub exists_eval { |
112
|
1
|
|
|
1
|
1
|
3
|
my ($res) = @_; |
113
|
1
|
|
|
|
|
2
|
return ( ${$res}->code eq '200' ); |
|
1
|
|
|
|
|
4
|
|
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
#}}} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
#{{{sub full_json_setup |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub full_json_setup { |
121
|
3
|
|
|
3
|
1
|
360
|
my ( $base_url, $remote_dest ) = @_; |
122
|
3
|
100
|
|
|
|
8
|
if ( !defined $base_url ) { croak 'No base url defined!'; } |
|
1
|
|
|
|
|
8
|
|
123
|
2
|
100
|
|
|
|
4
|
if ( !defined $remote_dest ) { |
124
|
1
|
|
|
|
|
8
|
croak 'No position or ID to retrieve full json for specified!'; |
125
|
|
|
|
|
|
|
} |
126
|
1
|
|
|
|
|
6
|
return "get $base_url/$remote_dest.infinity.json"; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
#}}} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
#{{{sub full_json_eval |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub full_json_eval { |
134
|
1
|
|
|
1
|
1
|
2
|
my ($res) = @_; |
135
|
1
|
|
|
|
|
2
|
return ( ${$res}->code eq '200' ); |
|
1
|
|
|
|
|
4
|
|
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
#}}} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
#{{{sub move_setup |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub move_setup { |
143
|
6
|
|
|
6
|
1
|
431
|
my ( $base_url, $remote_src, $remote_dest, $replace ) = @_; |
144
|
6
|
100
|
|
|
|
19
|
if ( !defined $base_url ) { croak 'No base url defined!'; } |
|
1
|
|
|
|
|
9
|
|
145
|
5
|
100
|
|
|
|
15
|
if ( !defined $remote_src ) { |
146
|
2
|
|
|
|
|
24
|
croak 'No content source to move from defined!'; |
147
|
|
|
|
|
|
|
} |
148
|
3
|
100
|
|
|
|
9
|
if ( !defined $remote_dest ) { |
149
|
1
|
|
|
|
|
7
|
croak 'No content destination to move to defined!'; |
150
|
|
|
|
|
|
|
} |
151
|
2
|
|
|
|
|
5
|
my $post_variables = |
152
|
|
|
|
|
|
|
"\$post_variables = [':dest','$remote_dest',':operation','move'"; |
153
|
2
|
100
|
|
|
|
6
|
$post_variables .= ( defined $replace ? q{,':replace','true'} : q{} ); |
154
|
2
|
|
|
|
|
3
|
$post_variables .= ']'; |
155
|
2
|
|
|
|
|
15
|
return "post $base_url/$remote_src $post_variables"; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
#}}} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
#{{{sub move_eval |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub move_eval { |
163
|
1
|
|
|
1
|
1
|
2
|
my ($res) = @_; |
164
|
1
|
|
|
|
|
1
|
return ( ${$res}->code =~ /^20(0|1)$/msx ); |
|
1
|
|
|
|
|
4
|
|
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
#}}} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
#{{{sub upload_file_setup |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub upload_file_setup { |
172
|
6
|
|
|
6
|
1
|
536
|
my ( $base_url, $local_path, $remote_dest, $filename ) = @_; |
173
|
6
|
100
|
|
|
|
16
|
if ( !defined $base_url ) { |
174
|
1
|
|
|
|
|
8
|
croak 'No base URL provided to upload against!'; |
175
|
|
|
|
|
|
|
} |
176
|
5
|
100
|
|
|
|
12
|
if ( !defined $local_path ) { croak 'No local file to upload defined!'; } |
|
2
|
|
|
|
|
22
|
|
177
|
3
|
100
|
|
|
|
6
|
if ( !defined $remote_dest ) { |
178
|
1
|
|
|
|
|
12
|
croak "No remote path to upload to defined for file $local_path!"; |
179
|
|
|
|
|
|
|
} |
180
|
2
|
100
|
|
|
|
9
|
if ( $filename eq q{} ) { $filename = './*'; } |
|
1
|
|
|
|
|
2
|
|
181
|
2
|
|
|
|
|
3
|
my $post_variables = '$post_variables = []'; |
182
|
|
|
|
|
|
|
return |
183
|
2
|
|
|
|
|
13
|
"fileupload $base_url/$remote_dest $filename $local_path $post_variables"; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
#}}} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
#{{{sub upload_file_eval |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub upload_file_eval { |
191
|
1
|
|
|
1
|
1
|
3
|
my ($res) = @_; |
192
|
1
|
|
|
|
|
2
|
return ( ${$res}->code =~ /^20(0|1)$/msx ); |
|
1
|
|
|
|
|
7
|
|
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
#}}} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
1; |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
__END__ |