Elive/Connection/SDK.pm

filter: Statementstmt 65.5% 61 / 93 Branchbran 26.9% 7 / 26 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 76.1% 16 / 21 Podpod 100% 7 / 7 totaltotal 60.6% 91 / 150 CC 15 SCAR 20.1
CC
15
Cov
56%
soap
30.0
_preamble
12.0
connect
6.0
CRAP 7.5
« Elive/Entity.pm ↑ Summary Elive/Entity/Group.pm »
1 package Elive::Connection::SDK;
2 21 ▶use warnings; use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 21 ▶use Class::Accessor;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 21 ▶use Class::Data::Inheritable;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 21 ▶use HTML::Entities;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 21 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 21 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 21 ▶use parent qw{Elive::Connection};
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 21 ▶use Elive;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 21 ▶use Elive::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 21 ▶use Elive::Entity;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 21 ▶use Elive::Entity::User;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 21 ▶use Elive::Entity::ServerDetails;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 =head1 NAME
20  
21 Elive::Connection::SDK - Manage Elluminate Live SDK SOAP connections.
22  
23 =head1 DESCRIPTION
24  
25 This module handles logical connections to Elluminate I<Live!> sites.
26  
27 Most of the time, you won't need to use this module directly, rather
28 you'll create a default connection via L<Elive>:
29  
30 Elive->connect('https://someserver.com', 'someuser', 'somepass');
31  
32 However, if you need to manage multiple sites and/or servers. You can
33 have multiple connections:
34  
35 my $connection1
36 = Elive::Connection->connect('https://someserver.com/site1',
37 'user1' => 'pass1',
38 timeout => 100,
39 );
40  
41 my $connection2
42 = Elive::Connection->connect('https://user2:pass2@someserver.com/site2');
43  
44 =cut
45  
46 21 __PACKAGE__->mk_accessors( qw{_login _server_details} );
47  
48 21 our %KnownCommands = (
49  
50 addGroupMember => 'c',
51 addMeetingPreload => 'c',
52 addReport => 'c',
53  
54 attendanceNotification => 'r',
55  
56 changePassword => 'u',
57  
58 buildMeetingJNLP => 'r',
59 buildRecordingJNLP => 'r',
60 buildReport => 'r',
61  
62 checkMeetingPreload => 'r',
63  
64 createGroup => 'c',
65 createMeeting => 'c',
66 createPreload => 'c',
67 createRecording => 'c',
68 createSession => 'c',
69 createUser => 'c',
70  
71 deleteGroup => 'd',
72 deleteMeeting => 'd',
73 deleteMeetingPreload => 'd',
74 deleteParticipant => 'd',
75 deleteRecording => 'd',
76 deleteReport => 'd',
77 deletePreload => 'd',
78 deleteUser => 'd',
79  
80 getGroup => 'r',
81 getMeeting => 'r',
82 getMeetingParameters => 'r',
83 getPreload => 'r',
84 getPreloadStream => 'r',
85 getRecording => 'r',
86 getReport => 'r',
87 getRecordingStream => 'r',
88 getReport => 'r',
89 getServerDetails => 'r',
90 getServerParameters => 'r',
91 getUser => 'r',
92  
93 importPreload => 'c',
94 importRecording => 'c',
95  
96 isModerator => 'r',
97 isParticipant => 'r',
98  
99 listGroups => 'r',
100 listMeetingPreloads => 'r',
101 listMeetings => 'r',
102 listParticipants => 'r',
103 listPreloads => 'r',
104 listRecordings => 'r',
105 listReports => 'r',
106 listUserMeetingsByDate => 'r',
107 listUsers => 'r',
108  
109 resetGroup => 'u',
110 resetParticipantList => 'u',
111  
112 setParticipantList => 'u',
113  
114 streamPreload => 'u',
115 streamRecording => 'u',
116  
117 updateGroup => 'u',
118 updateMeeting => 'u',
119 updateMeetingParameters => 'u',
120 updateRecording => 'u',
121 updateReport => 'u',
122 updateServerParameters => 'u',
123 updateSession => 'u',
124 updateUser => 'u',
125 );
126  
127 21 __PACKAGE__->mk_classdata(known_commands => \%KnownCommands);
128  
129 =head2 connect
130  
131 my $ec1 = Elive::Connection::SDK->connect('https://someserver.com/test',
132 'user1', 'pass1', debug => 1);
133  
134 my $url1 = $ec1->url; # 'https://someserver.com/test'
135  
136 my $ec2 = Elive::Connection::SDK->connect('http://user2:pass2@someserver.com/test', undef, undef, debug => 1);
137 my $url2 = $ec2->url; # 'http://someserver.com/test'
138  
139 Establishes a SOAP connection over C<http>/C<https>. Retrieves the login user,
140 to verify connectivity and authentication details.
141  
142 =cut
143  
144 sub connect {
145 0 ▶ my ($class, $url, $user, $pass, %opt) = @_;
Subroutine connect: not called CC=2 SCAR=17.9
Pod documented
146  
147 0 my $self = $class->_connect($url, $user, $pass, %opt);
148 0 bless $self, $class;
149 #
150 # The login name should be a valid user in the database.
151 # retrieve it as a way of authenticating the user and
152 # checking basic connectivity.
153 #
154 0 ▶ $self->login
Branch: 1 branch
BranchTrueFalseTotal
$self->login or croak("not logged in") 0 0 0
155 or croak "not logged in";
156  
157 0 return $self;
158 }
159  
160 =head2 disconnect
161  
162 Closes a connection and frees any resources related to the connection.
163  
164 =cut
165  
166 sub disconnect {
167 25 ▶ my $self = shift;
Subroutine disconnect: called CC=1 SCAR=0.0
Pod documented
168  
169 25 $self->SUPER::disconnect;
170  
171 25 $self->_server_details(undef);
172 25 $self->_login(undef);
173  
174 25 return;
175 }
176  
177 =head2 soap
178  
179 my $soap_lite_obj = $connection->soap;
180  
181 Returns the underlying L<SOAP::Lite> object for the connection.
182  
183 =cut
184  
185 sub soap {
186 0 ▶ my $self = shift;
Subroutine soap: not called CC=5 SCAR=34.0
Pod documented
187  
188 0 my $soap = $self->_soap;
189  
190 0 ▶ unless ($soap) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($soap) 0 0 0
191  
192 0 my $proxy = join('/', $self->url, 'webservice.event');
193  
194 0 my $debug = $self->debug;
195  
196 0 ▶ SOAP::Lite::import($debug >= 3
Branch: 1 branch
BranchTrueFalseTotal
$debug >= 3 ? : 0 0 0
197 ? (+trace => 'debug')
198 : ()
199 );
200  
201 0 ▶ warn "connecting to ".$proxy
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
202 if ($debug);
203  
204 0 $soap = SOAP::Lite->new();
205  
206 0 my %proxy_opts;
207 0 ▶ $proxy_opts{timeout} = $self->timeout
Branch: 1 branch
BranchTrueFalseTotal
if $self->timeout 0 0 0
208 if $self->timeout;
209  
210 0 $soap->proxy($proxy, %proxy_opts);
211  
212 0 $self->_soap($soap);
213 }
214  
215 0 return $soap;
216 }
217  
218 =head2 call
219  
220 my $som = $self->call( $cmd, %params );
221  
222 Performs an Elluminate SOAP method call. Returns the response as a
223 SOAP::SOM object.
224  
225 =cut
226  
227 sub call {
228 0 ▶ my ($self, $cmd, %params) = @_;
Subroutine call: not called CC=2 SCAR=17.9
Pod documented
229  
230 0 ▶ $params{adapter} ||= 'default';
Condition0%0/2
$params{"adapter"} ||= "default"
l!l
00
MC/DC0%0/1
$params{"adapter"} ||= "default"
$params{"adapter"}
Truth table0%0/2
A
A= $params{"adapter"}
Aresult
11
00
231  
232 0 return $self->SUPER::call( $cmd, %params );
233 }
234  
235 sub _preamble {
236  
237 0 ▶ my ($self,$cmd) = @_;
Subroutine _preamble: not called CC=3 SCAR=24.8
238  
239 0 ▶ die "Not logged in"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->user 0 0 0
240 unless ($self->user);
241  
242 0 my @user_auth = (map {HTML::Entities::encode_entities( $_ )}
243 ($self->user, $self->pass));
244  
245 0 my @preamble = (
246 (SOAP::Data
247 ->name('request')
248 ->uri('http://www.soapware.org')
249 ->prefix('m')
250 ->value('')),
251 );
252  
253 0 ▶ push (@preamble, SOAP::Data->name('command')->value($cmd))
Branch: 1 branch
BranchTrueFalseTotal
if $cmd 0 0 0
254 if $cmd;
255  
256 0 my $auth = sprintf (<<'EOD', @user_auth);
257 <h:BasicAuth
258 xmlns:h="http://soap-authentication.org/basic/2001/10/"
259 soap:mustUnderstand="1">
260 <Name>%s</Name>
261 <Password>%s</Password>
262 </h:BasicAuth>
263 EOD
264  
265 0 return (@preamble, SOAP::Header->type(xml => $auth));
266 };
267  
268 =head2 login
269  
270 Returns the login user as an object of type L<Elive::Entity::User>.
271  
272 =cut
273  
274 sub login {
275 19 ▶ my ($self) = @_;
Subroutine login: called CC=4 SCAR=14.0
Pod documented
276  
277 19 my $login_entity = $self->_login;
278  
279 19 ▶ unless ($login_entity) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($login_entity) 8 11 19
280  
281 8 ▶ my $username = $self->user
Branch: 1 branch
BranchTrueFalseTotal
my $username = $self->user or return 0 8 8
282 or return;
283  
284 8 ▶ $login_entity = Elive::Entity::User->get_by_loginName($username,
Branch: 1 branch
BranchTrueFalseTotal
$login_entity = "Elive::Entity::User"->get_by_loginName($username, "connection", $self) or die "unable to get login user: $username\n" 0 8 8
285 connection => $self)
286 or die "unable to get login user: $username\n";
287  
288 8 $self->_login($login_entity);
289 }
290  
291 19 return $login_entity;
292 }
293  
294 =head2 server_details
295  
296 Returns the server details as an object of type L<Elive::Entity::ServerDetails>.
297  
298 =cut
299  
300 sub server_details {
301 5 ▶ my $self = shift;
Subroutine server_details: called CC=3 SCAR=11.0
Pod documented
302  
303 5 my $server_details = $self->_server_details;
304  
305 5 ▶ unless ($server_details) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($server_details) 5 0 5
306  
307 5 $server_details = Elive::Entity::ServerDetails->list(connection => $self);
308 5 $self->_server_details($server_details);
309 }
310  
311 #
312 # this site could be running multiple servers
313 #
314  
315 5 ▶ return wantarray ? @$server_details : $server_details->[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 3 2 5
316 }
317  
318 =head2 version
319  
320 Return the Elluminate I<Live!> Server version
321  
322 =cut
323  
324 sub version {
325 0 ▶ my $self = shift;
Subroutine version: not called CC=2 SCAR=17.9
Pod documented
326 0 ▶ my $server_details = $self->server_details
Branch: 1 branch
BranchTrueFalseTotal
my $server_details = $self->server_details or die "Unable to get server details. Are all services running?\n" 0 0 0
327 or die "Unable to get server details. Are all services running?\n";
328 0 return $server_details->version;
329 }
330  
331 21 1;
« Elive/Entity.pm ↑ Summary Elive/Entity/Group.pm »