V3/Connection.pm

filter: Statementstmt 31.8% 43 / 135 Branchbran 0.0% 0 / 38 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 52.0% 13 / 25 Podpod 100% 10 / 10 totaltotal 30.2% 66 / 218 CC 22 SCAR 25.3
CC
22
Cov
24%
_check_for_errors
42.0
soap
20.0
connect
12.0
CRAP 12.6
« V3.pm ↑ Summary V3/_List.pm »
1 package Bb::Collaborate::V3::Connection;
2 3 ▶use warnings; use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 3 ▶use Bb::Collaborate::V3;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use Class::Accessor;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Class::Data::Inheritable;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶use SOAP::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use MIME::Base64;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use YAML::Syck;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 ▶use parent qw{Elive::Connection};
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 3 ▶use Elive;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 3 ▶use Elive::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 =head1 NAME
21  
22 Bb::Collaborate::V3::Connection - Manage Collaborate SOAP V3 endpoint connections.
23  
24 =head1 DESCRIPTION
25  
26 This module handles logical connections to the C<.../webservice.event> endpoint
27 on the Collaborate server. This endpoint implements the Standard Bridge API.
28  
29 =cut
30  
31 3 our %KnownCommands = (
32  
33 BuildRecordingUrl => 'r',
34 BuildSessionUrl => 'r',
35  
36 ClearSessionChairList => 'u',
37 ClearSessionNonChairList => 'u',
38  
39 ConvertRecording => 'r',
40  
41 GetQuotaLimits => 'r',
42 GetSchedulingManager => 'r',
43 GetServerConfiguration => 'r',
44 GetServerVersions => 'r',
45 GetTelephony => 'r',
46 GetTelephonyLicenseInfo => 'r',
47
48 ListRepositoryMultimedia => 'r',
49 ListRepositoryPresentation => 'r',
50 ListRecordingLong => 'r',
51 ListRecordingShort => 'r',
52 ListSession => 'r',
53 ListSessionAttendance => 'r',
54 ListSessionTelephony => 'r',
55 ListSessionMultimedia => 'r',
56 ListSessionPresentation => 'r',
57  
58 RemoveRepositoryMultimedia => 'd',
59 RemoveRepositoryPresentation => 'd',
60 RemoveSession => 'd',
61 RemoveRecording => 'd',
62 RemoveSessionMultimedia => 'd',
63 RemoveSessionPresentation => 'd',
64 RemoveSessionTelephony => 'd',
65  
66 SetApiCallbackUrl => 'r',
67 SetRecordingSecureSignOn => 'r',
68 SetSession => 'c',
69 SetSessionMultimedia => 'u',
70 SetSessionPresentation => 'u',
71 SetTelephony => 'u',
72  
73 UpdateSession => 'u',
74 UpdateSessionAttendees => 'u',
75 UploadRepositoryMultimedia => 'c',
76 UploadRepositoryPresentation => 'c',
77  
78 );
79  
80 3 __PACKAGE__->mk_classdata(known_commands => \%KnownCommands);
81  
82 #
83 # cache singleton records
84 #
85 3 __PACKAGE__->mk_accessors( qw{_scheduling_manager _server_configuration _server_versions _quota_limits
86 _telephony_license _authoriz _proxy} );
87  
88 =head2 connect
89  
90 my $con = Bb::Collaborate::V3::Connection->connect('https://xx-sas.bbcollab.com/site/external/adapter/default/v3',
91 'user1', 'pass1', debug => 1,
92 );
93  
94 my $url = $con->url; # 'https://xx-sas.bbcollab.com/site/external/adapter/default/v3.3/webservice.event'
95  
96 Establishes a SOAP connection. Retrieves the server configuration, to verify
97 connectivity, authentication and basic operation.
98  
99 =cut
100  
101 0 ▶sub connect {
Subroutine connect: not called CC=3 SCAR=24.8
Pod documented
102 0 my ($class, $url, $user, $pass, %opt) = @_;
103  
104 0 ▶ die "url $url does not contain the string: 'v3'"
Branch: 1 branch
BranchTrueFalseTotal
unless $url =~ /v3/ 0 0 0
105 unless $url =~ 'v3';
106  
107 0 my $self = $class->SUPER::_connect($url, $user, $pass, %opt);
108 0 bless $self, $class;
109  
110 $self->scheduling_manager
111 0 ▶ if $opt{ping};
Branch: 1 branch
BranchTrueFalseTotal
if $opt{"ping"} 0 0 0
112  
113 0 return $self;
114 }
115  
116 =head2 disconnect
117  
118 Closes a connection and frees any resources related to the connection.
119  
120 =cut
121  
122 0 ▶sub disconnect {
Subroutine disconnect: not called CC=1 SCAR=6.9
Pod documented
123 0 my $self = shift;
124  
125 0 $self->SUPER::disconnect;
126  
127 0 $self->_scheduling_manager(undef);
128 0 $self->_server_configuration(undef);
129 0 $self->_server_versions(undef);
130  
131 0 return;
132 }
133  
134 =head2 call
135  
136 my $som = $self->call( $cmd, %params );
137  
138 Performs a Collaborate SOAP method call. Returns the response as a
139 SOAP::SOM object.
140  
141 =cut
142  
143 =head2 soap
144  
145 my $soap_lite_obj = $connection->soap;
146  
147 Returns the underlying L<SOAP::Lite> object for the connection.
148  
149 =cut
150  
151 0 ▶sub soap {
Subroutine soap: not called CC=4 SCAR=30.0
Pod documented
152 0 my ($self) = shift;
153  
154 0 my $soap = $self->_soap;
155  
156 0 ▶ unless ($soap) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($soap) 0 0 0
157  
158 0 my $debug = $self->debug;
159  
160 0 ▶ SOAP::Lite::import($debug >= 3
Branch: 1 branch
BranchTrueFalseTotal
$debug >= 3 ? : 0 0 0
161 ? (+trace => 'debug')
162 : ()
163 );
164  
165 0 my $proxy = $self->url;
166 0 ▶ warn "connecting to ".$proxy
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
167 if ($debug);
168  
169 0 $soap = SOAP::Lite->new();
170 0 $soap->ns( "http://schemas.xmlsoap.org/soap/envelope" => "soapenv");
171 0 $soap->ns( "http://sas.elluminate.com/" => "sas");
172  
173 0 my %proxy_opts;
174  
175 0 $self->_proxy($proxy);
176 0 $soap->proxy($proxy);
177 #
178 # authentication adapted from www.perlmonks.org/index.pl?node_id=657873
179 #
180 0 my $authoriz = 'Basic '.MIME::Base64::encode_base64($self->user.':'.$self->pass);
181 0 $self->_authoriz( $authoriz );
182  
183 0 $soap->transport->http_request->headers->push_header(Authorization => $authoriz);
184  
185 0 $self->_soap($soap);
186 }
187  
188 0 return $soap;
189 }
190  
191 =head2 scheduling_manager
192  
193 Returns the scheduling manager for this connection (see L<Bb::Collaborate::V3::SchedulingManager>).
194  
195 =cut
196  
197 0 ▶sub scheduling_manager {
Subroutine scheduling_manager: not called CC=2 SCAR=17.9
Pod documented
198 0 my $self = shift;
199  
200 0 my $scheduling_manager = $self->_scheduling_manager;
201  
202 0 ▶ unless ($scheduling_manager) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($scheduling_manager) 0 0 0
203  
204 0 require Bb::Collaborate::V3::SchedulingManager;
205  
206 0 $scheduling_manager = Bb::Collaborate::V3::SchedulingManager->get(connection => $self);
207 0 $self->_scheduling_manager($scheduling_manager);
208 }
209  
210 0 return $scheduling_manager;
211 }
212  
213 =head2 server_configuration
214  
215 Returns the server configuration for this connection (see L<Bb::Collaborate::V3::Server::Configuration>).
216  
217 =cut
218  
219 0 ▶sub server_configuration {
Subroutine server_configuration: not called CC=3 SCAR=24.8
Pod documented
220 0 my $self = shift;
221  
222 0 my $server_configuration = $self->_server_configuration;
223  
224 0 ▶ unless ($server_configuration) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($server_configuration) 0 0 0
225  
226 0 require Bb::Collaborate::V3::Server::Configuration;
227  
228 0 $server_configuration = Bb::Collaborate::V3::Server::Configuration->list(connection => $self);
229 0 $self->_server_configuration($server_configuration);
230 }
231  
232 0 ▶ return wantarray ? @$server_configuration: $server_configuration->[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
233 }
234  
235 =head2 server_versions
236  
237 Returns the server versions for this connection (see L<Bb::Collaborate::V3::Server::Version>).
238  
239 =cut
240  
241 0 ▶sub server_versions {
Subroutine server_versions: not called CC=3 SCAR=24.8
Pod documented
242 0 my $self = shift;
243  
244 0 my $server_versions = $self->_server_versions;
245  
246 0 ▶ unless ($server_versions) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($server_versions) 0 0 0
247  
248 0 require Bb::Collaborate::V3::Server::Version;
249  
250 0 $server_versions = Bb::Collaborate::V3::Server::Version->list(connection => $self);
251 0 $self->_server_versions($server_versions);
252 }
253  
254 0 ▶ return wantarray ? @$server_versions : $server_versions->[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
255 }
256  
257 =head2 quota_limits
258  
259 Returns a list of available quotas and current usages.
260  
261 =cut
262  
263 0 ▶sub quota_limits {
Subroutine quota_limits: not called CC=3 SCAR=24.8
Pod documented
264 0 my $self = shift;
265  
266 0 my $quota_limits = $self->_quota_limits;
267  
268 0 ▶ unless ($quota_limits) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($quota_limits) 0 0 0
269  
270 0 require Bb::Collaborate::V3::Server::QuotaLimits;
271  
272 0 $quota_limits = Bb::Collaborate::V3::Server::QuotaLimits->list(connection => $self);
273 0 $self->_quota_limits($quota_limits);
274 }
275  
276 0 ▶ return wantarray ? @$quota_limits : $quota_limits;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
277 }
278  
279 =head2 telephony_license
280  
281 Returns the servers's telephony license, as a string. One of:
282  
283 =over 4
284  
285 =item (*) thirdParty - You must use your own teleconference
286 provider. You must manually configure the teleconference connection information.
287  
288 =item (*) integrated - The teleconference service is provided
289 by Blackboard Collaborate. Teleconference phone
290 numbers and PINs are automatically generated
291 during session creation and anyone in the session can
292 initiate the connection between the session and the
293 teleconference by simply dialing in to the
294 teleconference.
295  
296 =item (*) none - No teleconferencing is supported.
297  
298 =back
299  
300 =cut
301  
302 0 ▶sub telephony_license {
Subroutine telephony_license: not called CC=3 SCAR=24.8
Pod documented
303 0 my $self = shift;
304  
305 0 my $telephony_license = $self->_telephony_license;
306  
307 0 ▶ unless ($telephony_license) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($telephony_license) 0 0 0
308 0 my $som = $self->call('GetTelephonyLicenseInfo');
309 0 my $results = Bb::Collaborate::V3->_get_results( $som, $self );
310  
311 0 ▶ $telephony_license = @$results && $results->[0];
Condition0%0/3
@$results && $results->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
@$results && $results->[0]
@$results $results->[0]
Truth table0%0/3
A && B
A= @$resultsB= $results->[0]
ABresult
0X0
100
111
312 0 $self->_telephony_license( $telephony_license );
313 }
314  
315 0 return $telephony_license;
316 }
317  
318 0 ▶sub _preamble {
Subroutine _preamble: not called CC=3 SCAR=24.8
319 0 my ($self, $cmd) = @_;
320  
321 0 ▶ die "Not logged in"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->user 0 0 0
322 unless ($self->user);
323  
324 0 my @preamble = (
325 );
326  
327 0 ▶ push (@preamble, SOAP::Data->prefix('sas')->name($cmd))
Branch: 1 branch
BranchTrueFalseTotal
if $cmd 0 0 0
328 if $cmd;
329  
330 0 return @preamble;
331 };
332  
333 =head2 version
334  
335 Equivalent to C<$self-E<gt>server_versions-E<gt>versionName>.
336  
337 =cut
338  
339 0 ▶sub version {
Subroutine version: not called CC=1 SCAR=6.9
Pod documented
340 0 return (my $self = shift)->server_versions->versionName;
341 }
342  
343 =head2 url
344  
345 Return the SOAP end-point URL.
346  
347 =cut
348  
349 0 ▶sub url {
Subroutine url: not called CC=1 SCAR=6.9
Pod documented
350 0 my $self = shift;
351 0 return $self->SUPER::url(@_) . '/v3/webservice.event';
352 }
353  
354 0 ▶sub _check_for_errors {
Subroutine _check_for_errors: not called CC=6 SCAR=37.4
355 0 my $class = shift;
356 0 my $som = shift;
357  
358 0 ▶ croak "No response from server"
Branch: 1 branch
BranchTrueFalseTotal
unless $som 0 0 0
359 unless $som;
360  
361 0 $class->SUPER::_check_for_errors( $som );
362  
363 0 my $body = $som->body;
364  
365 0 ▶ if ( Elive::Util::_reftype( $body ) eq 'HASH'
Branch: 1 branch
BranchTrueFalseTotal
if (Elive::Util::_reftype($body) eq "HASH" and my $error_resp = $body->{"DefaultAdapterErrorResponse"}) 0 0 0
Condition0%0/3
Elive::Util::_reftype($body) eq "HASH" and my $error_resp = $body->{"DefaultAdapterErrorResponse"}
!ll&&!rl&&r
000
MC/DC0%0/2
Elive::Util::_reftype($body) eq "HASH" and my $error_resp = $body->{"DefaultAdapterErrorResponse"}
Elive::Util::_reftype($body) eq "HASH" my $error_resp = $body->{"DefaultAdapterErrorResponse"}
Truth table0%0/3
A and B
A= Elive::Util::_reftype($body) eq "HASH"B= my $error_resp = $body->{"DefaultAdapterErrorResponse"}
ABresult
0X0
100
111
366 && (my $error_resp = $body->{DefaultAdapterErrorResponse})) {
367  
368 0 ▶ unless (Elive::Util::_reftype( $error_resp ) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
unless (Elive::Util::_reftype($error_resp) eq "HASH") 0 0 0
369 0 Carp::cluck ("Unexpected response: ". YAML::Syck::Dump($body));
370 0 croak "error parsing DefaultAdapterErrorResponse";
371 }
372  
373 0 my $command = $error_resp->{command};
374 0 my $message = $error_resp->{message};
375 0 my $success = $error_resp->{success};
376  
377 0 my $msg = join(': ', grep {$_} ($command, $message));
378  
379 0 ▶ if ($success) {
Branch: 1 branch
BranchTrueFalseTotal
if ($success) { } 0 0 0
380 0 Carp::carp $msg
381 }
382 else {
383 0 Carp::croak $msg
384 }
385 }
386  
387 0 return;
388 }
389  
390 3 1;
« V3.pm ↑ Summary V3/_List.pm »