eXistDB/RPC.pm

filter: Statementstmt 14.2% 62 / 434 Branchbran 0.0% 0 / 206 Conditioncond 0.0% 0 / 58 MC/DCmcdc 0.0% 0 / 37 Subroutinesub 12.2% 12 / 98 Podpod 98.8% 82 / 83 totaltotal 17.0% 156 / 916 CC 132 SCAR 32.1
CC
132
Cov
9%
init
132.0
_document
72.0
uploadDocument
72.0
CRAP 24.8
↑ Summary eXistDB.pm »
1 # Copyrights 2010-2015 by [Mark Overmeer].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.01.
5 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 package XML::eXistDB::RPC;
9 5 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 $VERSION = '0.14';
11  
12  
13 5 ▶use Log::Report 'xml-existdb', syntax => 'LONG';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 5 ▶use XML::Compile::RPC::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use XML::Compile::RPC::Client ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 5 ▶use XML::eXistDB::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use XML::eXistDB;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 5 ▶use Digest::MD5 qw/md5_base64 md5_hex/;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 5 ▶use Encode qw/encode/;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 5 ▶use MIME::Base64 qw/encode_base64/;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 # to be removed later
26 5 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 5 $Data::Dumper::Indent = 1;
28  
29 5 my $dateTime = 'dateTime.iso8601'; # too high chance on typos
30  
31  
32 0 ▶sub new(@) { my $class = shift; (bless {}, $class)->init({@_}) }
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
33  
34 sub init($)
35 0 ▶{ my ($self, $args) = @_;
Subroutine init: not called CC=11 SCAR=48.8
Pod undocumented
36  
37 0 ▶ unless($self->{rpc} = $args->{rpc})
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"rpc"} = $args->{"rpc"}) 0 0 0
38 { my $dest = $args->{destination}
39 0 ▶ or report ERROR =>
Branch: 1 branch
BranchTrueFalseTotal
my $dest = $args->{"destination"} or &report("ERROR", &__x("{pkg} object required option `rpc' or `destination'", "pkg", ref $self)) 0 0 0
40 __x"{pkg} object required option `rpc' or `destination'"
41 , pkg => ref $self;
42 0 $self->{rpc} = XML::Compile::RPC::Client->new(destination => $dest);
43 }
44  
45 $self->{repository}
46 0 ▶ = exists $args->{repository} ? $args->{repository} : '/db';
Branch: 1 branch
BranchTrueFalseTotal
exists $args->{'repository'} ? : 0 0 0
47 $self->{compr_up}
48 0 ▶ = defined $args->{compress_upload} ? $args->{compress_upload} : 128;
Branch: 1 branch
BranchTrueFalseTotal
defined $args->{'compress_upload'} ? : 0 0 0
49 0 ▶ $self->{chunks} = defined $args->{chunk_size} ? $args->{chunk_size} : 32;
Branch: 1 branch
BranchTrueFalseTotal
defined $args->{'chunk_size'} ? : 0 0 0
50  
51 0 ▶ $self->login($args->{user} // 'guest', $args->{password} // 'guest');
Condition0%0/4
$args->{"user"} // "guest"
l!l
00
$args->{"password"} // "guest"
l!l
00
MC/DC0%0/1
$args->{"user"} // "guest"
$args->{"user"}
MC/DC0%0/1
$args->{"password"} // "guest"
$args->{"password"}
Truth table0%0/2
A
A= $args->{"user"}
Aresult
11
00
Truth table0%0/2
A
A= $args->{"password"}
Aresult
11
00
52 0 ▶ $self->{pp_up} = $args->{prettyprint_upload} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$args->{'prettyprint_upload'} ? : 0 0 0
53 0 $self->{schemas} = $args->{schemas};
54  
55 0 ▶ my $f = $args->{format} || [];
Condition0%0/2
$args->{'format'} || []
l!l
00
MC/DC0%0/1
$args->{'format'} || []
$args->{'format'}
Truth table0%0/2
A
A= $args->{'format'}
Aresult
11
00
56 0 ▶ $self->{format} = [ ref $f eq 'HASH' ? %$f : @$f ];
Branch: 1 branch
BranchTrueFalseTotal
ref $f eq 'HASH' ? : 0 0 0
57 0 $self;
58 }
59  
60 #-----------------
61  
62 # private method; "options" is an overloaded term, abused by eXist.
63 sub _format(@)
64 0 ▶{ my $self = shift;
Subroutine _format: not called CC=3 SCAR=24.8
65 0 my %args = (@{$self->{format}}, @_);
66  
67 0 ▶ if(my $sp = delete $args{'stylesheet-params'})
Branch: 1 branch
BranchTrueFalseTotal
if (my $sp = delete $args{"stylesheet-params"}) 0 0 0
68 0 ▶ { while(my($k,$v) = each %$sp)
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$sp) 0 0 0
69 0 { $args{"stylesheet-param.$k"} = $v;
70 }
71 }
72 0 struct_from_hash string => \%args;
73 }
74  
75 sub _date_options($$)
76 0 ▶{ my ($created, $modified) = @_;
Subroutine _date_options: not called CC=5 SCAR=34.0
77  
78 0 ▶ !($created || $modified) ? ()
Branch: 2 branches
BranchTrueFalseTotal
!($created || $modified) ? : 0 0 0
$created && $modified ? : 0 0 0
Condition0%0/6
$created || $modified
l!l&&r!l&&!r
000
$created and $modified
!ll&&!rl&&r
000
MC/DC0%0/2
$created || $modified
$created $modified
MC/DC0%0/2
$created and $modified
$created $modified
Truth table0%0/3
A || B
A= $createdB= $modified
ABresult
1X1
011
000
Truth table0%0/3
A and B
A= $createdB= $modified
ABresult
0X0
100
111
79 : ($created && $modified) ? ($dateTime => $created, $dateTime => $modified)
80 : report ERROR => "either both or neither creation and modification date";
81 }
82  
83  
84 sub _document($)
85 0 ▶{ my $self = shift;
Subroutine _document: not called CC=8 SCAR=42.8
86 return $_[0]->toString($self->{pp_up})
87 0 ▶ if UNIVERSAL::isa($_[0], 'XML::LibXML::Document');
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::isa($_[0], "XML::LibXML::Document") 0 0 0
88 0 ▶ return encode 'utf-8', ${$_[0]}
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq "SCALAR" 0 0 0
89 if ref $_[0] eq 'SCALAR';
90 0 ▶ return encode 'utf-8', $_[0]
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /^\s*\</ 0 0 0
91 if $_[0] =~ m/^\s*\</;
92 0 ▶ if($_[0] !~ m/[\r\n]/ && -f $_[0])
Branch: 1 branch
BranchTrueFalseTotal
if (not $_[0] =~ /[\r\n]/ and -f $_[0]) 0 0 0
Condition0%0/3
not $_[0] =~ /[\r\n]/ and -f $_[0]
!ll&&!rl&&r
000
MC/DC0%0/2
not $_[0] =~ /[\r\n]/ and -f $_[0]
not $_[0] =~ /[\r\n]/ -f $_[0]
Truth table0%0/3
not(A) and B
A= not $_[0] =~ /[\r\n]/B= -f $_[0]
ABresult
0X0
100
111
93 0 { local *DOC;
94 0 ▶ open DOC, '<:raw', $_[0]
Branch: 1 branch
BranchTrueFalseTotal
open DOC, "<:raw", $_[0] or &report("FAULT", "cannot read document from file $_[0]") 0 0 0
95 or report FAULT => "cannot read document from file $_[0]";
96 0 local $/ = undef;
97 0 my $xml = <DOC>;
98 0 ▶ close DOC
Branch: 1 branch
BranchTrueFalseTotal
close DOC or &report("FAULT", "read error for document from file $_[0]") 0 0 0
99 or report FAULT => "read error for document from file $_[0]";
100 0 return $xml;
101 }
102  
103 0 report ERROR => "do not understand document via $_[0]";
104 }
105  
106 #-----------------
107  
108 #T
109 0 ▶sub hasCollection($) { $_[0]->{rpc}->hasCollection(string => $_[1]) }
Subroutine hasCollection: not called CC=1 SCAR=6.9
Pod documented
110  
111  
112 0 ▶sub hasDocument($) { $_[0]->{rpc}->hasDocument(string => $_[1]) }
Subroutine hasDocument: not called CC=1 SCAR=6.9
Pod documented
113  
114  
115 #T
116 0 ▶sub isXACMLEnabled() {shift->{rpc}->isXACMLEnabled}
Subroutine isXACMLEnabled: not called CC=1 SCAR=6.9
Pod documented
117  
118  
119 sub backup($$$$)
120 0 ▶{ $_[0]->{rpc}->backup(string => $_[1], string => $_[2]
Subroutine backup: not called CC=1 SCAR=6.9
Pod documented
121 , string => $_[3], string => $_[4]);
122 }
123  
124  
125 sub shutdown(;$)
126 0 ▶{ my $self = shift;
Subroutine shutdown: not called CC=2 SCAR=17.9
Pod documented
127 0 ▶ $self->{rpc}->shutdown(@_ ? (int => shift) : ());
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
128 }
129  
130  
131 0 ▶sub sync() { shift->{rpc}->sync }
Subroutine sync: not called CC=1 SCAR=6.9
Pod documented
132  
133 #-----------------
134  
135 #T
136 sub createCollection($;$)
137 0 ▶{ my ($self, $coll, $date) = @_;
Subroutine createCollection: not called CC=2 SCAR=17.9
Pod documented
138 0 ▶ my @date = $date ? ($dateTime => $date) : ();
Branch: 1 branch
BranchTrueFalseTotal
$date ? : 0 0 0
139 0 $self->{rpc}->createCollection(string => $coll, @date);
140 }
141  
142  
143 #T
144 sub configureCollection($$%)
145 0 ▶{ my ($self, $coll, $conf, %args) = @_;
Subroutine configureCollection: not called CC=6 SCAR=37.4
Pod documented
146 my $format = (exists $args{beautify} ? $args{beautify} : $self->{pp_up})
147 0 ▶ ? 1 : 0;
Branch: 2 branches
BranchTrueFalseTotal
(exists $args{'beautify'} ? $args{'beautify'} : $self->{'pp_up'}) ? : 0 0 0
exists $args{'beautify'} ? : 0 0 0
148 0 my $config;
149  
150 0 ▶ if(UNIVERSAL::isa($conf, 'XML::LibXML::Document'))
Branch: 2 branches
BranchTrueFalseTotal
if (UNIVERSAL::isa($conf, 'XML::LibXML::Document')) { } 0 0 0
elsif (not ref $conf and $conf =~ /^\s*\</) { } 0 0 0
151 { # ready document, hopefully correct
152 0 $config = $conf->toString($format);
153 }
154 ▶ elsif(!ref $conf && $conf =~ m/^\s*\</)
Condition0%0/3
not ref $conf and $conf =~ /^\s*\</
!ll&&!rl&&r
000
MC/DC0%0/2
not ref $conf and $conf =~ /^\s*\</
not ref $conf $conf =~ /^\s*\</
Truth table0%0/3
not(A) and B
A= not ref $confB= $conf =~ /^\s*\</
ABresult
0X0
100
111
155 { # preformatted xml
156 0 $config = $conf;
157 }
158 else
159 0 { $config = $self->schemas->createCollectionConfig($conf, %args);
160 }
161  
162 0 $self->{rpc}->configureCollection(string => $coll, string => $config);
163 }
164  
165  
166 sub copyCollection($$;$)
167 0 ▶{ my ($self, $from, $sec) = (shift, shift, shift);
Subroutine copyCollection: not called CC=2 SCAR=17.9
Pod documented
168 0 my @param = (string => $from, string => $sec);
169 0 ▶ push @param, string => shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
170 0 $self->{rpc}->copyCollection(@param);
171 }
172  
173  
174 # the two params version is missing from the interface description, so
175 # we use a little work-around
176 sub moveCollection($$;$)
177 0 ▶{ my ($self, $from, $tocoll, $subcoll) = @_;
Subroutine moveCollection: not called CC=2 SCAR=17.9
Pod documented
178 0 ▶ defined $subcoll
Branch: 1 branch
BranchTrueFalseTotal
defined $subcoll or () = $tocoll =~ m[ ^ (.*) / ([^/]+) $ ]x 0 0 0
179 or ($tocoll, $subcoll) = $tocoll =~ m! ^ (.*) / ([^/]+) $ !x;
180  
181 0 $self->{rpc}->moveCollection(string => $from, string => $tocoll
182 , string => $subcoll);
183 }
184  
185  
186 #T
187 sub describeCollection(;$%)
188 0 ▶{ my $self = shift;
Subroutine describeCollection: not called CC=6 SCAR=37.4
Pod documented
189 0 ▶ my $coll = @_ % 2 ? shift : $self->{repository};
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 ? : 0 0 0
190 0 my %args = @_;
191 my ($rc, $data) = $args{documents}
192 ? $self->{rpc}->getCollectionDesc(string => $coll)
193 0 ▶ : $self->{rpc}->describeCollection(string => $coll);
Branch: 1 branch
BranchTrueFalseTotal
$args{'documents'} ? : 0 0 0
194 0 ▶ $rc==0 or return ($rc, $data);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $data 0 0 0
195  
196 0 my $h = struct_to_hash $data;
197 0 $h->{collections} = [ rpcarray_values $h->{collections} ];
198 0 ▶ if(my $docs = $h->{documents})
Branch: 1 branch
BranchTrueFalseTotal
if (my $docs = $h->{"documents"}) 0 0 0
199 0 { my %docs;
200 0 foreach (rpcarray_values $docs)
201 0 { my $h = struct_to_hash $_;
202 0 $docs{$h->{name}} = $h;
203 }
204 0 $h->{documents} =\%docs;
205 }
206 0 (0, $h);
207 }
208  
209  
210 #T
211 sub subCollections(;$)
212 0 ▶{ my ($self, $coll) = @_;
Subroutine subCollections: not called CC=4 SCAR=30.0
Pod documented
213 0 ▶ $coll ||= $self->{repository};
Condition0%0/3
$coll ||= $self->{"repository"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$coll ||= $self->{"repository"}
$coll $self->{"repository"}
Truth table0%0/3
A ||= B
A= $collB= $self->{"repository"}
ABresult
1X1
011
000
214 0 my ($rc, $data) = $_[0]->describeCollection($coll, documents => 0);
215 0 ▶ $rc==0 or return ($rc, $data);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $data 0 0 0
216 0 ▶ (0, map { "$data->{name}/$_" } @{$data->{collections} || []});
Condition0%0/2
$data->{'collections'} || []
l!l
00
MC/DC0%0/1
$data->{'collections'} || []
$data->{'collections'}
Truth table0%0/2
A
A= $data->{'collections'}
Aresult
11
00
217 }
218  
219  
220 #T
221 sub collectionCreationDate(;$)
222 0 ▶{ my ($self, $coll) = @_;
Subroutine collectionCreationDate: not called CC=2 SCAR=17.9
Pod documented
223 0 ▶ $coll ||= $self->{repository};
Condition0%0/3
$coll ||= $self->{"repository"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$coll ||= $self->{"repository"}
$coll $self->{"repository"}
Truth table0%0/3
A ||= B
A= $collB= $self->{"repository"}
ABresult
1X1
011
000
224 0 $self->{rpc}->getCreationDate(string => $coll);
225 }
226  
227  
228 #T
229 sub listResources(;$)
230 0 ▶{ my ($self, $coll) = @_;
Subroutine listResources: not called CC=4 SCAR=30.0
Pod documented
231 0 ▶ $coll ||= $self->{repository};
Condition0%0/3
$coll ||= $self->{"repository"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$coll ||= $self->{"repository"}
$coll $self->{"repository"}
Truth table0%0/3
A ||= B
A= $collB= $self->{"repository"}
ABresult
1X1
011
000
232 my ($rc, $details)
233 0 ▶ = $self->{rpc}->getDocumentListing($coll ? (string => $coll) : ());
Branch: 1 branch
BranchTrueFalseTotal
$coll ? : 0 0 0
234 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
235 0 ($rc, rpcarray_values $details);
236 }
237  
238  
239 #T
240 sub reindexCollection($)
241 0 ▶{ my ($self, $coll) = @_;
Subroutine reindexCollection: not called CC=1 SCAR=6.9
Pod documented
242 0 $self->{rpc}->reindexCollection(string => $coll);
243 }
244  
245  
246 #T
247 sub removeCollection($)
248 0 ▶{ my ($self, $coll) = @_;
Subroutine removeCollection: not called CC=1 SCAR=6.9
Pod documented
249 0 $self->{rpc}->removeCollection(string => $coll);
250 }
251  
252 #-----------------
253  
254 #T
255 sub login($;$)
256 0 ▶{ my ($self, $user, $password) = @_;
Subroutine login: not called CC=2 SCAR=17.9
Pod documented
257 0 $self->{user} = $user;
258 0 ▶ $self->{password} = defined $password ? $password : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $password ? : 0 0 0
259 0 $self->{rpc}->headers->header(Authorization => 'Basic '
260 . encode_base64("$user:$password", ''));
261 0 (0);
262 }
263  
264  
265 #T
266 sub listGroups()
267 0 ▶{ my ($rc, $details) = shift->{rpc}->getGroups;
Subroutine listGroups: not called CC=2 SCAR=17.9
Pod documented
268 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
269 0 (0, rpcarray_values $details);
270 }
271  
272  
273 #T
274 sub describeResourcePermissions($)
275 0 ▶{ my ($rc, $details) = $_[0]->{rpc}->getPermissions(string => $_[1]);
Subroutine describeResourcePermissions: not called CC=2 SCAR=17.9
Pod documented
276 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
277 0 ($rc, struct_to_hash $details);
278 }
279  
280  
281 #T
282 sub listDocumentPermissions($)
283 0 ▶{ my ($self, $coll) = @_;
Subroutine listDocumentPermissions: not called CC=4 SCAR=30.0
Pod documented
284 0 ▶ $coll ||= $self->{repository};
Condition0%0/3
$coll ||= $self->{"repository"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$coll ||= $self->{"repository"}
$coll $self->{"repository"}
Truth table0%0/3
A ||= B
A= $collB= $self->{"repository"}
ABresult
1X1
011
000
285 0 my ($rc, $details) = $_[0]->{rpc}->listDocumentPermissions(string => $coll);
286 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
287 0 my $h = struct_to_hash $details;
288 0 my %h;
289 0 ▶ while( my ($k,$v) = each %$h)
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$h) 0 0 0
290 0 { $h{$k} = [ rpcarray_values $v ];
291 }
292 0 (0, \%h);
293 }
294  
295  
296 #T
297 sub describeUser($)
298 0 ▶{ my ($self, $user) = @_;
Subroutine describeUser: not called CC=2 SCAR=17.9
Pod documented
299 0 my ($rc, $details) = $self->{rpc}->getUser(string => $user);
300 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
301 0 my $h = struct_to_hash $details;
302 0 $h->{groups} = [ rpcarray_values $h->{groups} ];
303 0 (0, $h);
304 }
305  
306  
307 #T
308 sub listUsers()
309 0 ▶{ my ($rc, $details) = shift->{rpc}->getUsers;
Subroutine listUsers: not called CC=3 SCAR=24.8
Pod documented
310 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
311 0 my %h;
312 0 foreach my $user (rpcarray_values $details)
313 0 { my $u = struct_to_hash $user;
314 0 $u->{groups} = [ rpcarray_values $u->{groups} ];
315 0 $h{$u->{name}} = $u;
316 }
317 0 (0, \%h);
318 }
319  
320  
321 #T
322 0 ▶sub removeUser($) { $_[0]->{rpc}->removeUser(string => $_[1]) }
Subroutine removeUser: not called CC=1 SCAR=6.9
Pod documented
323  
324  
325 sub setPermissions($$;$$)
326 0 ▶{ my ($self, $target, $perms, $user, $group) = @_;
Subroutine setPermissions: not called CC=4 SCAR=30.0
Pod documented
327  
328 0 ▶ my @chown = ($user && $group) ? (string => $user, string => $group) : ();
Branch: 1 branch
BranchTrueFalseTotal
$user && $group ? : 0 0 0
Condition0%0/3
$user and $group
!ll&&!rl&&r
000
MC/DC0%0/2
$user and $group
$user $group
Truth table0%0/3
A and B
A= $userB= $group
ABresult
0X0
100
111
329 0 ▶ $self->{rpc}->setPermissions(string => $target, @chown
Branch: 1 branch
BranchTrueFalseTotal
$perms =~ /\D/ ? : 0 0 0
330 , ($perms =~ m/\D/ ? 'string' : 'int') => $perms);
331 }
332  
333  
334 #T
335 sub setUser($$$;$)
336 0 ▶{ my ($self, $user, $password, $groups, $home) = @_;
Subroutine setUser: not called CC=3 SCAR=24.8
Pod documented
337 0 ▶ my @groups = ref $groups eq 'ARRAY' ? @$groups : $groups;
Branch: 1 branch
BranchTrueFalseTotal
ref $groups eq 'ARRAY' ? : 0 0 0
338  
339 0 ▶ $self->{rpc}->setUser(string => $user
Branch: 1 branch
BranchTrueFalseTotal
$home ? : 0 0 0
340 , string => md5_base64($password)
341 , string => md5_hex("$user:exist:$password")
342 , rpcarray_from(string => @groups)
343 , ($home ? (string => $home) : ())
344 );
345 }
346  
347  
348 #T
349 sub describeCollectionPermissions(;$)
350 0 ▶{ my ($self, $coll) = @_;
Subroutine describeCollectionPermissions: not called CC=4 SCAR=30.0
Pod documented
351 0 ▶ $coll ||= $self->{repository};
Condition0%0/3
$coll ||= $self->{"repository"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$coll ||= $self->{"repository"}
$coll $self->{"repository"}
Truth table0%0/3
A ||= B
A= $collB= $self->{"repository"}
ABresult
1X1
011
000
352 0 my ($rc, $data) = $self->{rpc}->listCollectionPermissions(string => $coll);
353 0 ▶ $rc==0 or return ($rc, $data);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $data 0 0 0
354 0 my $h = struct_to_hash $data;
355 0 my %p;
356 0 foreach my $relname (keys %$h)
357 0 { my %perms;
358 0 @perms{ qw/user group mode/ } = rpcarray_values $h->{$relname};
359 0 $p{"$coll/$relname"} = \%perms;
360 }
361 0 ($rc, \%p);
362 }
363  
364 #-----------------
365  
366 ### need two-arg version?
367 sub copyResource($$$)
368 0 ▶{ my $self = shift;
Subroutine copyResource: not called CC=1 SCAR=6.9
Pod documented
369 0 $self->{rpc}->copyResource(string=> $_[0], string=> $_[1], string=> $_[2]);
370 }
371  
372  
373 #T
374 sub uniqueResourceName(;$)
375 0 ▶{ my ($self, $coll) = @_;
Subroutine uniqueResourceName: not called CC=2 SCAR=17.9
Pod documented
376 0 ▶ $coll ||= $self->{repository};
Condition0%0/3
$coll ||= $self->{"repository"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$coll ||= $self->{"repository"}
$coll $self->{"repository"}
Truth table0%0/3
A ||= B
A= $collB= $self->{"repository"}
ABresult
1X1
011
000
377 0 $self->{rpc}->createResourceId(string => $coll);
378 }
379  
380  
381 sub describeResource($)
382 0 ▶{ my ($self, $resource) = @_;
Subroutine describeResource: not called CC=2 SCAR=17.9
Pod documented
383 0 my ($rc, $details) = $self->{rpc}->describeResource(string => $resource);
384 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
385 0 ($rc, struct_to_hash $details);
386 }
387  
388  
389 #T
390 sub countResources(;$)
391 0 ▶{ my ($self, $coll) = @_;
Subroutine countResources: not called CC=2 SCAR=17.9
Pod documented
392 0 ▶ $coll ||= $self->{repository};
Condition0%0/3
$coll ||= $self->{"repository"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$coll ||= $self->{"repository"}
$coll $self->{"repository"}
Truth table0%0/3
A ||= B
A= $collB= $self->{"repository"}
ABresult
1X1
011
000
393 0 $self->{rpc}->getResourceCount(string => $coll);
394 }
395  
396  
397 ### two-params version needed?
398 sub moveResource($$$)
399 0 ▶{ my $self = shift;
Subroutine moveResource: not called CC=1 SCAR=6.9
Pod documented
400 0 $self->{rpc}->moveResource(string=> $_[0], string=> $_[1], string=> $_[2]);
401 }
402  
403  
404 #T
405 sub getDocType($)
406 0 ▶{ my ($rc, $details) = $_[0]->{rpc}->getDocType(string => $_[1]);
Subroutine getDocType: not called CC=2 SCAR=17.9
Pod documented
407 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
408 0 ($rc, rpcarray_values $details);
409 }
410  
411  
412 #T
413 sub setDocType($$$$)
414 0 ▶{ my ($self, $doc, $name, $pub, $sys) = @_;
Subroutine setDocType: not called CC=1 SCAR=6.9
Pod documented
415 0 $self->{rpc}->setDocType(string => $doc
416 , string => $name, string => $pub, string => $sys);
417 }
418  
419  
420 0 ▶sub whoLockedResource($) {$_[0]->{rpc}->hasUserLock(string => $_[1]) }
Subroutine whoLockedResource: not called CC=1 SCAR=6.9
Pod documented
421  
422  
423 0 ▶sub unlockResource($) {$_[0]->{rpc}->unlockResource(string => $_[1]) }
Subroutine unlockResource: not called CC=1 SCAR=6.9
Pod documented
424  
425  
426 sub lockResource($;$)
427 0 ▶{ my ($self, $resource, $user) = @_;
Subroutine lockResource: not called CC=3 SCAR=24.8
Pod documented
428 $user ||= $self->{user}
429 0 ▶ or report ERROR => "no default username set nor specified for lock";
Branch: 1 branch
BranchTrueFalseTotal
$user ||= $self->{"user"} or &report("ERROR", "no default username set nor specified for lock") 0 0 0
Condition0%0/3
$user ||= $self->{"user"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$user ||= $self->{"user"}
$user $self->{"user"}
Truth table0%0/3
A ||= B
A= $userB= $self->{"user"}
ABresult
1X1
011
000
430 0 $self->{rpc}->lockResource(string => $resource, string => $user);
431 }
432  
433  
434 0 ▶sub removeResource($) { $_[0]->{rpc}->remove(string => $_[1]) }
Subroutine removeResource: not called CC=1 SCAR=6.9
Pod documented
435  
436 #--------------------
437  
438 #T
439 sub downloadDocument($@)
440 0 ▶{ my $self = shift;
Subroutine downloadDocument: not called CC=7 SCAR=40.3
Pod documented
441 0 my ($rc, $chunk) = $self->getDocumentData(@_);
442 0 ▶ $rc==0 or return ($rc, $chunk);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $chunk 0 0 0
443  
444 0 my @data = \$chunk->{data};
445 0 ▶ while($rc==0 && $chunk->{offset})
Branch: 1 branch
BranchTrueFalseTotal
if ($rc == 0 and $chunk->{"offset"}) 0 0 0
Condition0%0/3
$rc == 0 and $chunk->{"offset"}
!ll&&!rl&&r
000
MC/DC0%0/2
$rc == 0 and $chunk->{"offset"}
$rc == 0 $chunk->{"offset"}
Truth table0%0/3
A and B
A= $rc == 0B= $chunk->{"offset"}
ABresult
0X0
100
111
446 { ($rc, $chunk) = $chunk->{'supports-long-offset'}
447 ? $self->getNextExtendedChunk($chunk->{handle}, $chunk->{offset})
448 0 ▶ : $self->getNextChunk($chunk->{handle}, $chunk->{offset});
Branch: 1 branch
BranchTrueFalseTotal
$chunk->{'supports-long-offset'} ? : 0 0 0
449 0 ▶ $rc or push @data, \$chunk->{data};
Branch: 1 branch
BranchTrueFalseTotal
$rc or push @data, \$chunk->{"data"} 0 0 0
450 }
451 0 ▶ $rc==0 or return ($rc, $chunk);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $chunk 0 0 0
452  
453 0 (0, join '', map {$$_} @data);
454 }
455  
456 # does this also work for binary resources?
457  
458  
459 sub listResourceTimestamps($)
460 0 ▶{ my ($rc, $vector) = $_[0]->{rpc}->getTimestamps(string => $_[1]);
Subroutine listResourceTimestamps: not called CC=2 SCAR=17.9
Pod documented
461 0 ▶ $rc==0 or return ($rc, $vector);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $vector 0 0 0
462 0 (0, rpcarray_values $vector);
463 }
464  
465 #-----------------
466  
467 #T
468 sub uploadDocument($$@)
469 0 ▶{ my ($self, $resource, undef, %args) = @_;
Subroutine uploadDocument: not called CC=8 SCAR=42.8
Pod documented
470 0 my $doc = $self->_document($_[2]);
471  
472 0 ▶ my $chunks = exists $args{chunk_size} ? $args{chunk_size} : $self->{chunks};
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'chunk_size'} ? : 0 0 0
473 0 ▶ my $compr = exists $args{compress} ? $args{compress} : $args{compr_upload};
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'compress'} ? : 0 0 0
474 0 ▶ for ($chunks, $compr) { $_ *= 1024 if defined $_ }
Branch: 1 branch
BranchTrueFalseTotal
if defined $_ 0 0 0
475  
476 0 my @dates = _date_options $args{creation_date}, $args{modify_date};
477 0 my $replace = $args{replace};
478 0 ▶ my $mime = $args{mime_type} || 'text/xml';
Condition0%0/2
$args{'mime_type'} || 'text/xml'
l!l
00
MC/DC0%0/1
$args{'mime_type'} || 'text/xml'
$args{'mime_type'}
Truth table0%0/2
A
A= $args{'mime_type'}
Aresult
11
00
479  
480 # Send file in chunks
481 0 my $to_sent = length $doc;
482 0 my $sent = 0;
483 0 my $tmp;
484  
485 0 ▶ while($sent < $to_sent)
Branch: 1 branch
BranchTrueFalseTotal
if ($sent < $to_sent) 0 0 0
486 0 { (my $rc, $tmp) = $self->upload($tmp, substr($doc, $sent, $chunks));
487 0 ▶ $rc==0 or return ($rc, $tmp);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $tmp 0 0 0
488 0 $sent += $chunks;
489 }
490 0 $self->parseLocal($tmp, $resource, $replace, $mime, @dates);
491 }
492  
493  
494 0 ▶sub downloadBinary($) { $_[0]->{rpc}->getBinaryResource(string => $_[1]) }
Subroutine downloadBinary: not called CC=1 SCAR=6.9
Pod documented
495  
496  
497 sub uploadBinary($$$$;$$)
498 0 ▶{ my ($self, $resource, $bytes, $mime, $replace, $created, $modified) = @_;
Subroutine uploadBinary: not called CC=2 SCAR=17.9
Pod documented
499
500 $self->{rpc}->storeBinary
501 0 ▶ ( base64 => (ref $bytes ? $$bytes : $bytes)
Branch: 1 branch
BranchTrueFalseTotal
ref $bytes ? : 0 0 0
502 , string => $resource, string => $mime, boolean => $replace
503 , _date_options($created, $modified)
504 );
505 }
506  
507 #-----------------
508  
509 #T
510 ### compile doesn't return anything
511 sub compile($@)
512 0 ▶{ my ($self, $query) = (shift, shift);
Subroutine compile: not called CC=2 SCAR=17.9
Pod documented
513 0 my ($rc, $details) = $self->{rpc}->compile(base64 => $query
514 , $self->_format(@_));
515 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
516 0 (0, struct_to_hash $details);
517 }
518  
519  
520 #T
521 # printDiagnostics should accept a base64
522 sub describeCompile($@)
523 0 ▶{ my ($self, $query) = (shift, shift);
Subroutine describeCompile: not called CC=1 SCAR=6.9
Pod documented
524 0 $self->{rpc}->printDiagnostics(string => $query, $self->_format(@_));
525 }
526  
527  
528 sub execute($@)
529 0 ▶{ my ($self, $handle) = (shift, shift);
Subroutine execute: not called CC=2 SCAR=17.9
Pod documented
530 0 my ($rc, $details) = $self->{rpc}->execute(string => $handle
531 , $self->_format(@_));
532 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
533 0 (0, struct_to_hash $details);
534 }
535  
536 #-----------------
537  
538 sub executeQuery($@)
539 0 ▶{ my ($self, $query) = @_;
Subroutine executeQuery: not called CC=2 SCAR=17.9
Pod documented
540 0 ▶ my @enc = @_ % 2 ? (string => shift) : ();
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 ? : 0 0 0
541 0 $self->{rpc}->executeQuery(base64 => $query, @enc, $self->_format(@_));
542 }
543  
544  
545 0 ▶sub numberOfResults($) { $_[0]->{rpc}->getHits(int => $_[1]) }
Subroutine numberOfResults: not called CC=1 SCAR=6.9
Pod documented
546  
547  
548 #T
549 # what does "docid" mean?
550 sub describeResultSet($)
551 0 ▶{ my ($rc, $details) = $_[0]->{rpc}->querySummary(int => $_[1]);
Subroutine describeResultSet: not called CC=6 SCAR=37.4
Pod documented
552 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
553 0 my $results = struct_to_hash $details;
554 0 ▶ if(my $docs = delete $results->{documents})
Branch: 1 branch
BranchTrueFalseTotal
if (my $docs = delete $results->{"documents"}) 0 0 0
555 0 { my @docs;
556 0 foreach my $result (rpcarray_values $docs)
557 0 { my ($name, $id, $hits) = rpcarray_values $result;
558 0 push @docs, { name => $name, docid => $id, hits => $hits };
559 }
560 0 $results->{documents} = \@docs;
561 }
562 0 ▶ if(my $types = delete $results->{doctypes})
Branch: 1 branch
BranchTrueFalseTotal
if (my $types = delete $results->{"doctypes"}) 0 0 0
563 0 { my @types;
564 0 foreach my $result (rpcarray_values $types)
565 0 { my ($class, $hits) = rpcarray_values $result;
566 0 push @types, { class => $class, hits => $hits };
567 }
568 0 $results->{doctypes} = \@types;
569 }
570 0 ($rc, $results);
571 }
572  
573  
574 #### what kind of params from %args?
575 #### releaseQueryResult(int $resultid, int $hash) INT?
576 sub releaseResultSet($@)
577 0 ▶{ my ($self, $results, %args) = @_;
Subroutine releaseResultSet: not called CC=1 SCAR=6.9
Pod documented
578 0 $self->{rpc}->releaseQueryResult(int => $results, int => 0);
579 }
580  
581  
582 sub retrieveResult($$@)
583 0 ▶{ my ($self, $set, $pos) = (shift, shift, shift);
Subroutine retrieveResult: not called CC=2 SCAR=17.9
Pod documented
584 my ($rc, $bytes)
585 0 = $self->{rpc}->retrieve(int => $set, int => $pos, $self->_format(@_));
586 0 ▶ $rc==0 or return ($rc, $bytes);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $bytes 0 0 0
587 0 (0, $self->schemas->decodeXML($bytes));
588 }
589  
590  
591 # hitCount where describeResultSet() uses 'hits'
592 #T
593 sub retrieveResults($@)
594 0 ▶{ my ($self, $set) = (shift, shift);
Subroutine retrieveResults: not called CC=2 SCAR=17.9
Pod documented
595 0 my ($rc, $bytes) = $self->{rpc}->retrieveAll(int => $set
596 , $self->_format(@_));
597 0 ▶ $rc==0 or return ($rc, $bytes);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $bytes 0 0 0
598 0 (0, $self->schemas->decodeXML($bytes));
599 }
600  
601 #-----------------
602  
603 #T
604 # Vector query() is given as alternative but does not exist.
605 sub query($$$@)
606 0 ▶{ my ($self, $query, $limit) = (shift, shift, shift);
Subroutine query: not called CC=3 SCAR=24.8
Pod documented
607 0 ▶ my $first = @_ % 2 ? shift : 1;
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 ? : 0 0 0
608 0 my ($rc, $bytes) = $self->{rpc}->query(string => $query, int => $limit
609 , int => $first, $self->_format(@_));
610 0 ▶ $rc==0 or return ($rc, $bytes);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $bytes 0 0 0
611 0 (0, $self->schemas->decodeXML($bytes));
612 }
613  
614  
615 sub queryXPath($$$@)
616 0 ▶{ my ($self, $xpath, $doc, $node) = splice @_, 0, 4;
Subroutine queryXPath: not called CC=5 SCAR=34.0
Pod documented
617 0 my @args = (base64 => $xpath);
618 0 ▶ push @args, string => $doc, string => (defined $node ? $node : '')
Branch: 2 branches
BranchTrueFalseTotal
if defined $doc 0 0 0
defined $node ? : 0 0 0
619 if defined $doc;
620 0 my ($rc, $data) = $self->{rpc}->queryP(@args, $self->_format(@_));
621 0 ▶ $rc==0 or return ($rc, $data);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $data 0 0 0
622  
623 0 my $h = struct_to_hash $data;
624 0 my @r;
625 0 foreach (rpcarray_values $h->{results})
626 0 { my ($doc, $loc) = rpcarray_values $_;
627 0 push @r, { document => $doc, node_id => $loc };
628 }
629 0 $h->{results} = \@r;
630  
631 0 (0, $h);
632 }
633
634 #-----------------
635  
636 sub retrieveDocumentNode($$@)
637 0 ▶{ my $self = shift;
Subroutine retrieveDocumentNode: not called CC=6 SCAR=37.4
Pod documented
638 0 my ($rc, $chunk) = $self->{rpc}->retrieveFirstChunk(@_);
639  
640 0 my @data = \$chunk->{data};
641 0 ▶ while($rc==0 && $chunk->{offset})
Branch: 1 branch
BranchTrueFalseTotal
if ($rc == 0 and $chunk->{"offset"}) 0 0 0
Condition0%0/3
$rc == 0 and $chunk->{"offset"}
!ll&&!rl&&r
000
MC/DC0%0/2
$rc == 0 and $chunk->{"offset"}
$rc == 0 $chunk->{"offset"}
Truth table0%0/3
A and B
A= $rc == 0B= $chunk->{"offset"}
ABresult
0X0
100
111
642 { ($rc, $chunk) = $chunk->{'supports-long-offset'}
643 ? $self->getNextExtendedChunk($chunk->{handle}, $chunk->{offset})
644 0 ▶ : $self->getNextChunk($chunk->{handle}, $chunk->{offset});
Branch: 1 branch
BranchTrueFalseTotal
$chunk->{'supports-long-offset'} ? : 0 0 0
645 0 ▶ $rc or push @data, \$chunk->{data};
Branch: 1 branch
BranchTrueFalseTotal
$rc or push @data, \$chunk->{"data"} 0 0 0
646 }
647 0 ▶ $rc==0 or return ($rc, $chunk);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $chunk 0 0 0
648  
649 0 (0, $self->schemas->decodeXML(join '', map {$$_} @data));
650 }
651  
652 #-----------------
653  
654 ### What does the returned int mean?
655 sub updateResource($$;$)
656 0 ▶{ my ($self, $resource, $xupdate, $encoding) = @_;
Subroutine updateResource: not called CC=2 SCAR=17.9
Pod documented
657 0 ▶ $self->{rpc}->xupdateResource(string => $resource, string => $xupdate
Branch: 1 branch
BranchTrueFalseTotal
$encoding ? : 0 0 0
658 , ($encoding ? (string => $encoding) : ()));
659 }
660  
661 ### What does the returned int mean?
662 ### Does this update the collection configuration?
663  
664 sub updateCollection($$)
665 0 ▶{ $_[0]->{rpc}->xupdate(string => $_[1], string => $_[2]);
Subroutine updateCollection: not called CC=1 SCAR=6.9
Pod documented
666 }
667  
668 #-----------------
669  
670 sub scanIndexTerms($$$;$)
671 0 ▶{ my $self = shift;
Subroutine scanIndexTerms: not called CC=3 SCAR=24.8
Pod documented
672 0 my ($rc, $details);
673 0 ▶ if(@_==4)
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 4) { } 0 0 0
674 0 { my ($coll, $begin, $end, $recurse) = @_;
675 0 ($rc, $details) = $self->{rpc}->scanIndexTerms(string => $coll
676 , string => $begin, string => $end, boolean => $recurse);
677 }
678 else
679 0 { my ($xpath, $begin, $end) = @_;
680 ### no idea what xpath means here.
681 0 ($rc, $details) = $self->{rpc}->scanIndexTerms(string => $xpath
682 , string => $begin, string => $end);
683 }
684  
685 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
686 0 (0, rpcarray_values $details);
687 }
688  
689  
690 sub getIndexedElements($$)
691 0 ▶{ my ($self, $coll, $recurse) = @_;
Subroutine getIndexedElements: not called CC=2 SCAR=17.9
Pod documented
692 0 my ($rc, $details) = $self->{rpc}->getIndexedElements(string => $coll
693 , boolean => $recurse);
694 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
695 ### cleanup Vector $details. Per element:
696 # 1. name of the element
697 # 2. optional namespace URI
698 # 3. optional namespace prefix
699 # 4. number of occurrences of this element as an integer value
700  
701 0 (0, rpcarray_values $details);
702 }
703  
704  
705 #-----------------
706  
707 sub schemas()
708 0 ▶{ my $self = shift;
Subroutine schemas: not called CC=3 SCAR=24.8
Pod documented
709 0 ▶ return $self->{schemas} if $self->{schemas};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"schemas"} 0 0 0
710  
711 # This will load a lot of XML::Compile::* modules. Therefore, we
712 # do this lazy: only when needed.
713 0 eval "require XML::eXistDB";
714 0 ▶ panic $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
715  
716 0 $self->{schemas} = XML::eXistDB->new;
717 }
718  
719  
720 0 ▶sub trace() { shift->{rpc}->trace }
Subroutine trace: not called CC=1 SCAR=6.9
Pod documented
721  
722 #----------------
723  
724 #T
725 sub getCollectionDesc(;$)
726 0 ▶{ my ($self, $coll) = @_;
Subroutine getCollectionDesc: not called CC=2 SCAR=17.9
Pod documented
727 0 ▶ $coll ||= $self->{repository};
Condition0%0/3
$coll ||= $self->{"repository"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$coll ||= $self->{"repository"}
$coll $self->{"repository"}
Truth table0%0/3
A ||= B
A= $collB= $self->{"repository"}
ABresult
1X1
011
000
728 0 $self->describeCollection($coll, documents => 1);
729 }
730  
731 #---------
732  
733 sub getDocument($$;$$)
734 0 ▶{ my ($self, $resource) = (shift, shift);
Subroutine getDocument: not called CC=4 SCAR=30.0
Pod documented
735 0 my @args;
736 0 ▶ if(@_==3)
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) { } 0 0 0
737 0 { my ($enc, $prettyprint, $style) = @_;
738 0 ▶ push @args, string => $enc, int => ($prettyprint ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
$prettyprint ? : 0 0 0
739 0 ▶ push @args, string => $style if defined $style;
Branch: 1 branch
BranchTrueFalseTotal
if defined $style 0 0 0
740 }
741 else
742 0 { @args = @_;
743 }
744 0 $self->{rpc}->getDocument(string => $resource, @args);
745 }
746  
747  
748 sub getDocumentAsString($$;$$)
749 0 ▶{ my ($self, $resource) = (shift, shift);
Subroutine getDocumentAsString: not called CC=4 SCAR=30.0
Pod documented
750 0 my @args;
751 0 ▶ if(@_==3)
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) { } 0 0 0
752 0 { my ($enc, $prettyprint, $style) = @_;
753 0 ▶ push @args, string => $enc, int => ($prettyprint ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
$prettyprint ? : 0 0 0
754 0 ▶ push @args, string => $style if defined $style;
Branch: 1 branch
BranchTrueFalseTotal
if defined $style 0 0 0
755 }
756 else
757 0 { @args = @_;
758 }
759 0 $self->{rpc}->getDocumentAsString(string => $resource, @args);
760 }
761  
762  
763 sub getDocumentData($@)
764 0 ▶{ my ($self, $resource) = (shift, shift);
Subroutine getDocumentData: not called CC=2 SCAR=17.9
Pod documented
765 0 my ($rc, $details) = $self->{rpc}->getDocumentData(string => $resource
766 , $self->_format(@_));
767 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
768 0 (0, struct_to_hash $details);
769 }
770  
771  
772 sub getNextChunk($$)
773 0 ▶{ my ($self, $handle, $offset) = @_;
Subroutine getNextChunk: not called CC=2 SCAR=17.9
Pod documented
774 my ($rc, $details)
775 0 = $self->{rpc}->getNextChunk(string => $handle, int => $offset);
776 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
777 0 (0, struct_to_hash $details);
778 }
779  
780  
781 sub getNextExtendedChunk($$)
782 0 ▶{ my ($self, $handle, $offset) = @_;
Subroutine getNextExtendedChunk: not called CC=2 SCAR=17.9
Pod documented
783 my ($rc, $details)
784 0 = $self->{rpc}->getNextChunk(string => $handle, string => $offset);
785 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
786 0 (0, struct_to_hash $details);
787 }
788  
789 #---------
790  
791 sub parse($$;$$$)
792 0 ▶{ my ($self, $data, $resource, $replace, $created, $modified) = @_;
Subroutine parse: not called CC=2 SCAR=17.9
Pod documented
793
794 $self->{rpc}->parse
795 0 ▶ ( base64 => $self->_document($data)
Branch: 1 branch
BranchTrueFalseTotal
$replace ? : 0 0 0
796 , string => $resource, int => ($replace ? 1 : 0)
797 , _date_options($created, $modified)
798 );
799 }
800  
801  
802 sub parseLocal($$$$;$$)
803 0 ▶{ my ($self, $fn, $resource, $replace, $mime, $created, $modified) = @_;
Subroutine parseLocal: not called CC=1 SCAR=6.9
Pod documented
804
805 $self->{rpc}->parseLocal
806 0 ( string => $fn, string => $resource, boolean => $replace
807 , string => $mime, _date_options($created, $modified)
808 );
809 }
810  
811  
812 sub parseLocalExt($$$$;$$)
813 0 ▶{ my ($self, $fn, $res, $replace, $mime, $is_xml, $created, $modified) = @_;
Subroutine parseLocalExt: not called CC=1 SCAR=6.9
Pod documented
814
815 $self->{rpc}->parseLocal
816 0 ( string => $fn, string => $res, boolean => $replace
817 , string => $mime, boolean => $is_xml
818 , _date_options($created, $modified)
819 );
820 };
821  
822  
823 sub upload($;$)
824 0 ▶{ my $self = shift;
Subroutine upload: not called CC=3 SCAR=24.8
Pod documented
825 0 ▶ my $tmp = @_ == 2 ? shift : undef;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 ? : 0 0 0
826 0 ▶ $self->{rpc}->upload(string => (defined $tmp ? $tmp : '')
Branch: 1 branch
BranchTrueFalseTotal
defined $tmp ? : 0 0 0
827 , base64 => $_[0], int => length($_[0]));
828 }
829  
830  
831 sub uploadCompressed($;$)
832 0 ▶{ my $self = shift;
Subroutine uploadCompressed: not called CC=3 SCAR=24.8
Pod documented
833 0 ▶ my $tmp = @_ == 3 ? shift : undef;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 ? : 0 0 0
834  
835 ### Not sure whether each chunk is compressed separately or the
836 ### data is compressed as a whole.
837 $self->{rpc}->uploadCompressed
838 0 ▶ ( (defined $tmp ? (string => $tmp) : ())
Branch: 1 branch
BranchTrueFalseTotal
defined $tmp ? : 0 0 0
839 , base64 => $_[0], int => length($_[1]));
840 }
841  
842  
843 0 ▶sub storeBinary($$$$;$$) { $_[0]->uploadBinary( @_[2, 1, 3, 4, 5, 6] ) }
Subroutine storeBinary: not called CC=1 SCAR=6.9
Pod documented
844  
845 #-------
846  
847 sub retrieveFirstChunk($$@)
848 0 ▶{ my $self = shift;
Subroutine retrieveFirstChunk: not called CC=3 SCAR=24.8
Pod documented
849 0 my @args;
850 0 ▶ if($_[0] =~ m/\D/)
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ /\D/) { } 0 0 0
851 0 { my ($docname, $id) = (shift, shift);
852 0 @args = (string => $docname, string => $id);
853 }
854 else
855 0 { my ($resultset, $pos) = (shift, shift);
856 0 @args = (int => $resultset, int => $pos);
857 }
858 0 my $format = $self->_format(@_);
859 0 my ($rc, $details) = $self->{rpc}->retrieveFirstChunk(@args, $format);
860 0 ▶ ($rc, $rc==0 ? $details : struct_to_hash $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 ? : 0 0 0
861 }
862  
863 #------------------
864  
865 sub retrieve($$@)
866 0 ▶{ my $self = shift;
Subroutine retrieve: not called CC=3 SCAR=24.8
Pod documented
867 0 ▶ my @args = $_[0] =~ m/\D/
Branch: 1 branch
BranchTrueFalseTotal
$_[0] =~ /\D/ ? : 0 0 0
868 ? (string => shift, string => shift)
869 : (int => shift, int => shift);
870  
871 0 my ($rc, $bytes) = $self->{rpc}->retrieve(@args, $self->_format(@_));
872 0 ▶ $rc==0 or return ($rc, $bytes);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $bytes 0 0 0
873 0 (0, $self->schemas->decodeXML($bytes));
874 }
875  
876  
877 sub retrieveAll($$@)
878 0 ▶{ my ($self, $set) = (shift, shift);
Subroutine retrieveAll: not called CC=2 SCAR=17.9
Pod documented
879 0 my ($rc, $bytes) = $self->{rpc}->retrieveAll(int => $set
880 , $self->_format(@_));
881 0 ▶ $rc==0 or return ($rc, $bytes);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $bytes 0 0 0
882 0 (0, $self->schemas->decodeXML($bytes));
883 }
884  
885  
886 sub retrieveAllFirstChunk($$@)
887 0 ▶{ my ($self, $result) = (shift, shift);
Subroutine retrieveAllFirstChunk: not called CC=2 SCAR=17.9
Pod documented
888 0 my ($rc, $details) = $self->{rpc}->retrieveAllFirstChunk(int => $result
889 , $self->_format(@_));
890 0 ▶ $rc==0 or return ($rc, $details);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $details 0 0 0
891 0 (0, struct_to_hash $details);
892 }
893  
894  
895 sub isValidDocument($)
896 0 ▶{ my ($self, $doc) = (shift, shift);
Subroutine isValidDocument: not called CC=1 SCAR=6.9
Pod documented
897 0 $self->{rpc}->isValid(string => $doc);
898 }
899  
900  
901 sub initiateBackup($)
902 0 ▶{ my ($self, $s) = (shift, shift);
Subroutine initiateBackup: not called CC=1 SCAR=6.9
Pod documented
903 0 $self->{rpc}->dataBackup($s);
904 }
905  
906  
907 sub getDocumentChunked($@)
908 0 ▶{ my ($self, $doc) = (shift, shift);
Subroutine getDocumentChunked: not called CC=2 SCAR=17.9
Pod documented
909 0 my ($rc, $data) = $self->{rpc}->getDocumentChunk(string => $doc);
910 0 ▶ $rc==0 or return ($rc, $data);
Branch: 1 branch
BranchTrueFalseTotal
$rc == 0 or return $rc, $data 0 0 0
911 0 (0, rpcarray_values $data);
912 }
913  
914  
915 sub getDocumentNextChunk($$$)
916 0 ▶{ my ($self, $handle, $start, $len) = @_;
Subroutine getDocumentNextChunk: not called CC=1 SCAR=6.9
Pod documented
917 0 $self->{rpc}->getDocumentChunck(string => $handle
918 , int => $start, int => $len);
919 }
920  
921  
922 sub retrieveAsString($$@)
923 0 ▶{ my ($self, $doc, $node) = (shift, shift, shift);
Subroutine retrieveAsString: not called CC=1 SCAR=6.9
Pod documented
924 0 $self->{rpc}->retrieveAsString(string => $doc, string => $node
925 , $self->_format(@_));
926 }
927  
928 #----------------
929  
930 5 *createResourceId = \&uniqueResourceName;
931 5 *dataBackup = \&initiateBackup;
932 5 *getBinaryResource = \&downloadBinary;
933 5 *getCreationDate = \&collectionCreationDate;
934 5 *getDocumentListing = \&listResources;
935 5 *getGroups = \&listGroups;
936 5 *getHits = \&numberOfResults;
937 5 *getPermissions = \&describeResourcePermissions;
938 5 *getResourceCount = \&countResources;
939 5 *getTimestamps = \&listResourceTimestamps;
940 5 *getUser = \&describeUser;
941 5 *getUsers = \&listUsers;
942 5 *hasUserLock = \&whoLockedResource;
943 5 *isValid = \&isValidDocument;
944 5 *listCollectionPermissions = \&describeCollectionPermissions;
945 5 *printDiagnostics = \&describeCompile;
946 5 *querySummary = \&describeResultSet;
947 5 *queryP = \&queryXPath;
948 5 *releaseQueryResult = \&releaseResultSet;
949 5 *remove = \&removeResource;
950 5 *xupdate = \&xupdateCollection;
951 5 *xupdateResource = \&xupdateResource;
952  
953 5 1;
↑ Summary eXistDB.pm »