blib/lib/FedoraCommons/APIA.pm

filter: Statementstmt 13.5% 30 / 221 Branchbran 1.0% 1 / 94 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 7 / 21 Podpod 91.6% 11 / 12 totaltotal 14.0% 49 / 348 CC 51 SCAR 41.8
CC
51
Cov
10%
new
182.0
findObjects
72.0
listDatastreams
72.0
CRAP 65.3
↑ Summary
1 # ========================================================================= #
2 #
3 # FedoraCommons::APIA - interface to Fedora's SOAP based API-A
4 #
5 # ========================================================================= #
6 #
7 # Copyright (c) 2011, Cornell University www.cornell.edu (enhancements)
8 # Copyright (c) 2010, Cornell University www.cornell.edu (enhancements)
9 # Copyright (c) 2007, The Pennsylvania State University, www.psu.edu
10 #
11 # This library is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2, or (at your option)
14 # any later version.
15 #
16 # See pod documentation for further license and copyright information.
17 #
18 # History: APIA interface was developed at PSU in 2006/2007. This code
19 # was built on top of an existing module which used SOAP (Technical
20 # Knowledge Center of Denmark[2006]).
21 #
22 # Cornell University began using the module for scripts
23 # to import legacy digital collections into a new cloud-based
24 # Archival Repository (2009). During this work the module has been
25 # enhanced with several new methods implemented.
26 #
27 # The module made interacting with a Fedora Commons repository
28 # easy thus the decision to share the module on CPAN.
29 #
30 #
31 # Manifest of APIA API methods and APIA Module methods:
32 # POD
33 # Fedora 3.0 APIA API Methods Supported Status Documented
34 # --------------------------- --------- ------ ----------
35 #
36 # * Repository Access
37 # o describeRepository No
38 # * Object Access
39 # o findObjects Supported OK Yes
40 # o resumeFindObjects Supported OK Yes
41 # o getObjectHistory No
42 # o getObjectProfile No
43 # * Datastream Access
44 # o getDatastreamDissemination Supported OK Yes
45 # o listDatastreams Supported OK Yes (PSU)
46 # * Dissemination Access
47 # o getDissemination No
48 # o listMethods No
49 #
50 # Local Additions:
51 #
52 # * Datastream Access
53 # o datastreamExists Supported OK Yes
54 #
55 #
56 # *PSU - Implemented by Penn State University
57 #
58 # ========================================================================= #
59 #
60 # $Id: APIA.pm,v 1.3 2007/06/25 15:22:25 dlf2 Exp $
61 #
62 # ========================================================================= #
63 #
64  
65 package FedoraCommons::APIA;
66  
67 1 ▶use 5.008005;
Subroutine BEGIN: called CC=1 SCAR=0.0
68 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
69 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
70  
71 1 require SOAP::Lite;
72 1 ▶use Time::HiRes qw(time);
Subroutine BEGIN: called CC=1 SCAR=0.0
73 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
74  
75 1 require Exporter;
76 1 ▶use AutoLoader qw(AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
77  
78 1 our @ISA = qw(Exporter);
79  
80 # Items to export into callers namespace by default. Note: do not export
81 # names by default without a very good reason. Use EXPORT_OK instead.
82 # Do not simply export all your public functions/methods/constants.
83  
84 # This allows declaration use FedoraCommons::APIA ':all';
85 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
86 # will save memory.
87 1 our %EXPORT_TAGS = ( 'all' => [ qw(
88  
89 ) ] );
90  
91 1 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
92  
93 1 our @EXPORT = qw(
94  
95 );
96  
97 1 our $VERSION = '0.5';
98  
99 1 our $FEDORA_VERSION = "3.2";
100  
101 1 ▶sub import {
Subroutine import: called CC=4 SCAR=24.2
102 1 my $pkg = shift;
103 1 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 1 1
104 0 my $command = shift;
105 0 my $parameter = shift;
106 0 ▶ if ($command eq 'version') {
Branch: 1 branch
BranchTrueFalseTotal
if ($command eq "version") 0 0 0
107  
108 # Add legal Fedora version numbers as they become available
109 0 ▶ if ($parameter eq "3.2") {
Branch: 1 branch
BranchTrueFalseTotal
if ($parameter eq "3.2") 0 0 0
110 0 $FEDORA_VERSION = $parameter;
111 }
112  
113 }
114 }
115 }
116  
117 1 my $ERROR_MESSAGE;
118  
119 # Preloaded methods go here.
120  
121 # Autoload methods go after =cut, and are processed by the autosplit program.
122  
123  
124  
125 # ========================================================================= #
126 #
127 # Public Methods
128 #
129 # ========================================================================= #
130  
131  
132  
133 # Constructor
134 #
135 # Args in parameter hash:
136 # host : Fedora host
137 # port : Port
138 # usr : Fedora Admin user
139 # pwd : Fedora Admin password
140 # timeout: Allowed timeout
141 #
142 # Return:
143 # The Fedora::APIA object
144 #
145 0 ▶sub new {
Subroutine new: not called CC=13 SCAR=52.0
Pod documented
146 0 my $class = shift;
147 0 my %args = @_;
148 0 my $self = {};
149 0 $self->{'protocol'} = "http";
150  
151 0 foreach my $k (keys %args) {
152 0 ▶ if ($k eq 'usr') {
Branch: 6 branches
BranchTrueFalseTotal
if ($k eq 'usr') { } 0 0 0
elsif ($k eq 'pwd') { } 0 0 0
elsif ($k eq 'host') { } 0 0 0
elsif ($k eq 'port') { } 0 0 0
elsif ($k eq 'timeout') { } 0 0 0
elsif ($k eq 'protocol') { } 0 0 0
153 0 $self->{$k} = $args{$k};
154 } elsif ( $k eq 'pwd') {
155 0 $self->{$k} = $args{$k};
156 } elsif ( $k eq 'host') {
157 0 $self->{$k} = $args{$k};
158 } elsif ( $k eq 'port') {
159 0 $self->{$k} = $args{$k};
160 } elsif ( $k eq 'timeout') {
161 0 $self->{$k} = $args{$k};
162 } elsif ( $k eq 'protocol') {
163 0 $self->{$k} = $args{$k};
164 }
165 }
166  
167 # Check mandatory parameters
168 0 ▶ Carp::croak "Initialisation parameter 'host' missing" unless defined($self->{'host'});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"host"} 0 0 0
169 0 ▶ Carp::croak "Initialisation parameter 'port' missing" unless defined($self->{'port'});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"port"} 0 0 0
170 0 ▶ Carp::croak "Initialisation parameter 'usr' missing" unless defined($self->{'usr'});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"usr"} 0 0 0
171 0 ▶ Carp::croak "Initialisation parameter 'pwd' missing" unless defined($self->{'pwd'});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"pwd"} 0 0 0
172  
173 # Bless object
174 0 bless $self;
175
176 # Initialise SOAP class
177 0 my $apia=SOAP::Lite
178 -> uri("http://www.fedora.info/definitions/api/")
179 -> proxy($self->_get_proxy());
180 0 ▶ if (defined($self->{timeout})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"timeout"}) 0 0 0
181 0 $apia->proxy->timeout($self->{timeout});
182 }
183 0 $self->{apia} = $apia;
184  
185 0 return $self;
186 }
187  
188 # Error from most recent operation
189 0 ▶sub error {
Subroutine error: not called CC=1 SCAR=6.9
Pod documented
190 0 my $self = shift;
191 0 return $self->{ERROR_MESSAGE};
192 }
193  
194 # Elapsed time of most recent operation
195 0 ▶sub get_time {
Subroutine get_time: not called CC=1 SCAR=6.9
Pod documented
196 0 my $self = shift;
197 0 return $self->{TIME};
198 }
199  
200 # Statistics
201 0 ▶sub get_stat {
Subroutine get_stat: not called CC=1 SCAR=6.9
Pod documented
202 0 my $self = shift;
203 0 return $self->{STAT};
204 }
205  
206 0 ▶sub get_proxy {
Subroutine get_proxy: not called CC=1 SCAR=6.9
Pod undocumented
207 0 my $self = shift;
208 0 return $self->_get_proxy();
209 }
210  
211 # Start statistic gathering over
212 0 ▶sub start_stat {
Subroutine start_stat: not called CC=1 SCAR=6.9
Pod documented
213 0 my $self = shift;
214 0 $self->{STAT} = {};
215 0 return;
216 }
217  
218 # findObjects
219 #
220 # Args in parameter hash:
221 # maxResults: Max number of results returned
222 # fldsrchProperty: The field (aka property) being searched
223 # fldsrchValue: Operator for comparing a property to a value
224 # fldsrchOperator: The value of the field being searched
225 # searchRes_ref: Reference to scalar to hold search results
226 #
227 # Return:
228 #
229 # 0 = success
230 # 1 = Error
231 # 2 = Error on remote server
232 #
233 0 ▶sub findObjects{
Subroutine findObjects: not called CC=8 SCAR=42.8
Pod documented
234 0 my $self = shift;
235 0 my %args = @_;
236  
237 0 $self->{ERROR_MESSAGE}=undef;
238 0 $self->{TIME}=undef;
239  
240 0 ▶ Carp::croak "Parameter 'maxResults' missing" unless defined($args{maxResults});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"maxResults"} 0 0 0
241 0 ▶ Carp::croak "Parameter 'fldsrchProperty' missing" unless defined($args{fldsrchProperty});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"fldsrchProperty"} 0 0 0
242 0 ▶ Carp::croak "Parameter 'fldsrchOperator' missing" unless defined($args{fldsrchOperator});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"fldsrchOperator"} 0 0 0
243 0 ▶ Carp::croak "Parameter 'fldsrchValue' missing" unless defined($args{fldsrchValue});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"fldsrchValue"} 0 0 0
244 Carp::croak "Parameter 'searchRes_ref' missing" unless defined($args{searchRes_ref})
245 0 ▶;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"searchRes_ref"} 0 0 0
246  
247 # List Datastreams
248 0 my $findobjs_result;
249 0 eval {
250 0 my $start=time;
251 $findobjs_result = $self->{apia}->findObjects(
252 SOAP::Data->name('resultFields'=> \SOAP::Data->value('pid')),
253 SOAP::Data->name('maxResults')->value($args{maxResults})->type('xsd:nonNegativeInteger'),
254 SOAP::Data->name('query'=> \SOAP::Data->value(
255 SOAP::Data->name("conditions" => \SOAP::Data->value(
256 SOAP::Data->name("condition" => \SOAP::Data->value(
257 SOAP::Data->name("property" => $args{fldsrchProperty}),
258 SOAP::Data->name("operator" => $args{fldsrchOperator})->type('xsd:enumeration'),
259 0 SOAP::Data->name("value" => $args{fldsrchValue})))))))
260 );
261 0 my $elapse_time = time - $start;
262 0 $self->{TIME} = $elapse_time;
263 0 $self->{STAT}->{'findObjects'}{count}++;
264 0 $self->{STAT}->{'findObjects'}{time} += $elapse_time;
265 };
266 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
267 0 $self->{ERROR_MESSAGE}=$self->_handle_exceptions($@);
268 0 return 1;
269 }
270  
271 # Handle error from Fedora target
272 0 ▶ if ($findobjs_result->fault) {
Branch: 1 branch
BranchTrueFalseTotal
if ($findobjs_result->fault) 0 0 0
273 $self->{ERROR_MESSAGE}=
274 0 $findobjs_result->faultcode."; ".
275 $findobjs_result->faultstring."; ".
276 $findobjs_result->faultdetail;
277 0 return 2;
278 }
279  
280 # Handle success
281 0 ${$args{searchRes_ref}} = $findobjs_result->result();
282 0 return 0;
283  
284 }
285  
286  
287 # resumeFindObjects
288 #
289 # Args in parameter hash:
290 # sessionToken:
291 # searchRes_ref: Reference to scalar to hold search results
292 #
293 # Return:
294 #
295 # 0 = success
296 # 1 = Error
297 # 2 = Error on remote server
298 #
299 0 ▶sub resumeFindObjects{
Subroutine resumeFindObjects: not called CC=5 SCAR=34.0
Pod documented
300 0 my $self = shift;
301 0 my %args = @_;
302  
303 0 $self->{ERROR_MESSAGE}=undef;
304 0 $self->{TIME}=undef;
305  
306 0 ▶ Carp::croak "Parameter 'sessionToken' missing" unless defined($args{sessionToken});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"sessionToken"} 0 0 0
307 Carp::croak "Parameter 'searchRes_ref' missing" unless defined($args{searchRes_ref})
308 0 ▶;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"searchRes_ref"} 0 0 0
309  
310 # List Datastreams
311 0 my $resumefindobjs_result;
312 0 eval {
313 0 my $start=time;
314 0 $resumefindobjs_result = $self->{apia}->resumeFindObjects($args{sessionToken});
315 0 my $elapse_time = time - $start;
316 0 $self->{TIME} = $elapse_time;
317 0 $self->{STAT}->{'resumeFindObjects'}{count}++;
318 0 $self->{STAT}->{'resumeFindObjects'}{time} += $elapse_time;
319 };
320 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
321 0 $self->{ERROR_MESSAGE}=$self->_handle_exceptions($@);
322 0 return 1;
323 }
324  
325 # Handle error from Fedora target
326 0 ▶ if ($resumefindobjs_result->fault) {
Branch: 1 branch
BranchTrueFalseTotal
if ($resumefindobjs_result->fault) 0 0 0
327 $self->{ERROR_MESSAGE}=
328 0 $resumefindobjs_result->faultcode."; ".
329 $resumefindobjs_result->faultstring."; ".
330 $resumefindobjs_result->faultdetail;
331 0 return 2;
332 }
333  
334 # Handle success
335 0 ${$args{searchRes_ref}} = $resumefindobjs_result->result();
336 0 return 0;
337  
338 }
339  
340  
341 # getDatastreamDissemination
342 #
343 # Args in parameter hash:
344 # pid: Record PID in fedora
345 # dsID: Datastream PID
346 # asOfDateTime
347 # stream_ref Reference to scalar to hold resulting stream
348 #
349 # Return:
350 #
351 # 0 = success
352 # 1 = Error
353 # 2 = Error on remote server
354 #
355 0 ▶sub getDatastreamDissemination {
Subroutine getDatastreamDissemination: not called CC=7 SCAR=40.3
Pod documented
356 0 my $self = shift;
357 0 my %args = @_;
358  
359 0 $self->{ERROR_MESSAGE}=undef;
360 0 $self->{TIME}=undef;
361  
362 0 ▶ Carp::croak "Parameter 'pid' missing" unless defined($args{pid});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"pid"} 0 0 0
363 0 ▶ Carp::croak "Parameter 'dsID' missing" unless defined($args{dsID});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"dsID"} 0 0 0
364 Carp::croak "Parameter 'stream_ref' missing" unless defined($args{stream_ref})
365 0 ▶;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"stream_ref"} 0 0 0
366  
367 # Set Defaults
368 0 ▶ if (!defined($args{asOfDateTime})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"asOfDateTime"}) 0 0 0
369 0 $args{asOfDateTime} = "undef";
370 }
371  
372 # Get Datastream Dissemination
373 0 my $gdd_result;
374 0 eval {
375 0 my $start=time;
376 $gdd_result = $self->{apia}->getDatastreamDissemination(
377 $args{pid},
378 $args{dsID},
379 # $args{asOfDateTime},
380 undef,
381 0 );
382 0 my $elapse_time = time - $start;
383 0 $self->{TIME} = $elapse_time;
384 0 $self->{STAT}->{'getDatastreamDissemination'}{count}++;
385 0 $self->{STAT}->{'getDatastreamDissemination'}{time} += $elapse_time;
386 };
387 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
388 0 $self->{ERROR_MESSAGE}=$self->_handle_exceptions($@);
389 0 return 1;
390 }
391  
392 # Handle error from Fedora target
393 0 ▶ if ($gdd_result->fault) {
Branch: 1 branch
BranchTrueFalseTotal
if ($gdd_result->fault) 0 0 0
394 $self->{ERROR_MESSAGE}=
395 0 $gdd_result->faultcode."; ".
396 $gdd_result->faultstring."; ".
397 $gdd_result->faultdetail;
398 0 return 2;
399 }
400  
401 # Handle success
402 # Decode Stream
403 0 ${$args{stream_ref}} = MIME::Base64::decode_base64($gdd_result->result()->{'stream'});
404
405 0 return 0;
406  
407 }
408  
409  
410 # listDatastreams
411 #
412 # Args in parameter hash:
413 # pid: Record PID in fedora
414 # asOfDateTime:
415 # datastream_ref: Reference to scalar to hold result
416 # list: Reference to list. When provides will create list of
417 # datastream ids.
418 #
419 # Return:
420 #
421 # 0 = success
422 # 1 = Error
423 # 2 = Error on remote server
424 #
425 0 ▶sub listDatastreams{
Subroutine listDatastreams: not called CC=8 SCAR=42.8
Pod documented
426 0 my $self = shift;
427 0 my %args = @_;
428  
429 0 $self->{ERROR_MESSAGE}=undef;
430 0 $self->{TIME}=undef;
431  
432 0 ▶ Carp::croak "Parameter 'pid' missing" unless defined($args{pid});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"pid"} 0 0 0
433 0 ▶ Carp::croak "Parameter 'datastream_ref' missing" unless defined($args{datastream_ref});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"datastream_ref"} 0 0 0
434  
435 # Set Defaults
436 0 ▶ if (!defined($args{asOfDateTime})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"asOfDateTime"}) 0 0 0
437 0 $args{asOfDateTime} = "undef";
438 }
439  
440 # List Datastreams
441 0 my $lds_result;
442 0 eval {
443 0 my $start=time;
444 $lds_result = $self->{apia}->listDatastreams(
445 $args{pid},
446 # $args{asOfDateTime},
447 undef
448 0 );
449 0 my $elapse_time = time - $start;
450 0 $self->{TIME} = $elapse_time;
451 0 $self->{STAT}->{'listDatastreams'}{count}++;
452 0 $self->{STAT}->{'listDatastreams'}{time} += $elapse_time;
453 };
454 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
455 0 $self->{ERROR_MESSAGE}=$self->_handle_exceptions($@);
456 0 return 1;
457 }
458  
459 # Handle error from Fedora target
460 0 ▶ if ($lds_result->fault) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lds_result->fault) 0 0 0
461 $self->{ERROR_MESSAGE}=
462 0 $lds_result->faultcode."; ".
463 $lds_result->faultstring."; ".
464 $lds_result->faultdetail;
465 0 return 2;
466 }
467  
468 # Does the user want a list of datastream identifiers.
469 0 ▶ if ($args{list}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"list"}) 0 0 0
470  
471 0 my $datastreams;
472 0 $datastreams = $lds_result;
473  
474 0 foreach my $ds ($datastreams->valueof('//datastreamDef')) {
475 0 push(@{$args{list}},$ds->{ID});
476 }
477 }
478  
479 # Handle success
480 0 ${$args{datastream_ref}} = $lds_result;
481 0 return 0;
482  
483 }
484  
485 # datastreamExists (Boolean)
486 #
487 # Args in parameter hash:
488 # pid: Record PID in fedora
489 # dsID: Datastream identifier. Will check
490 # existence of datastream.
491 #
492 # Return:
493 #
494 # 0 = False, datastream does not exist
495 # 1 = True, datastream exists
496 #
497 0 ▶sub datastreamExists {
Subroutine datastreamExists: not called CC=6 SCAR=37.4
Pod documented
498 0 my $self = shift;
499 0 my %args = @_;
500  
501 0 ▶ Carp::croak "Parameter 'pid' missing" unless defined($args{pid});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"pid"} 0 0 0
502 0 ▶ Carp::croak "Parameter 'dsID' missing" unless defined($args{dsID});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"dsID"} 0 0 0
503  
504  
505  
506 0 my $pid = $args{'pid'};
507 0 my $dsID = $args{'dsID'};
508 0 my $datastreams;
509  
510 0 ▶ if ($self->listDatastreams(pid=>$pid,
Branch: 1 branch
BranchTrueFalseTotal
if ($self->listDatastreams("pid", $pid, "datastream_ref", \$datastreams) == 0) 0 0 0
511 datastream_ref =>\$datastreams) == 0) {
512 0 my @dslist = ();
513  
514 0 foreach my $ds ($datastreams->valueof('//datastreamDef')) {
515 0 push(@dslist,$ds->{ID});
516 }
517 0 ▶ if (grep $dsID eq $_, @dslist) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep(($dsID eq $_), @dslist)) { } 0 0 0
518 0 return 1;
519 } else {
520 0 return 0;
521 }
522 }
523 0 return 0;
524 }
525  
526  
527  
528 # getObjectProfile
529 #
530 # Args in parameter hash:
531 # pid: PID of the object
532 # asOfDateTime:
533 # profile_ref: reference to return metadata profile
534 #
535 # Return:
536 #
537 # 0 = success
538 # 1 = Error
539 # 2 = Error on remote server
540 #
541 0 ▶sub getObjectProfile {
Subroutine getObjectProfile: not called CC=6 SCAR=37.4
Pod documented
542 0 my $self = shift;
543 0 my %args = @_;
544  
545 0 $self->{ERROR_MESSAGE}=undef;
546 0 $self->{TIME}=undef;
547  
548 0 ▶ Carp::croak "Parameter 'pid' missing" unless defined($args{pid});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"pid"} 0 0 0
549 0 ▶ Carp::croak "Parameter 'profile_ref' missing" unless defined($args{profile_ref});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"profile_ref"} 0 0 0
550  
551 # Set Defaults
552 0 ▶ if (!defined($args{asOfDateTime})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"asOfDateTime"}) 0 0 0
553 0 $args{asOfDateTime} = "undef";
554 }
555 0 my $gds_result;
556 0 eval {
557 0 my $start=time;
558 $gds_result = $self->{apia}->getObjectProfile (
559 $args{pid},
560 0 );
561 0 my $elapse_time = time - $start;
562 0 $self->{TIME} = $elapse_time;
563 0 $self->{STAT}->{'getDatastream'}{count}++;
564 0 $self->{STAT}->{'getDatastream'}{time} += $elapse_time;
565 };
566 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
567 0 $self->{ERROR_MESSAGE}=$self->_handle_exceptions($@);
568 0 return 1;
569 }
570  
571 # Handle error from Fedora target
572 0 ▶ if ($gds_result->fault) {
Branch: 1 branch
BranchTrueFalseTotal
if ($gds_result->fault) 0 0 0
573 $self->{ERROR_MESSAGE}=
574 0 $gds_result->faultcode."; ".
575 $gds_result->faultstring."; ".
576 $gds_result->faultdetail;
577 0 return 2;
578 }
579  
580 0 my $data = $gds_result->result();
581  
582 # Handle success
583 0 ${$args{profile_ref}} = $gds_result->result();
584 0 return 0;
585  
586 } # getObjectProfile
587  
588 ###
589  
590 # ========================================================================= #
591 #
592 # Private Methods
593 #
594 # ========================================================================= #
595  
596  
597  
598 # Map die exceptions from SOAP::Lite calls to Fedora::APIA error messages
599 0 ▶sub _handle_exceptions {
Subroutine _handle_exceptions: not called CC=2 SCAR=17.9
600 0 my ($self, $exception_text) = @_;
601 0 ▶ if ($exception_text =~ m{^401 Unauthorized}) { return "401 Unauthorized"; }
Branch: 1 branch
BranchTrueFalseTotal
if ($exception_text =~ /^401 Unauthorized/) 0 0 0
602 0 return $exception_text;
603 }
604  
605 # Method for constructing proxy URL
606 0 ▶sub _get_proxy {
Subroutine _get_proxy: not called CC=1 SCAR=6.9
607 0 my ($self) = @_;
608 return "$self->{'protocol'}://".
609 $self->{usr}.":".$self->{pwd}.
610 "\@".$self->{host}.":".$self->{port}.
611 0 "/fedora/services/access";
612 }
613  
614 1 1;
615 __END__
↑ Summary