eXistDB/RPC.pm

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