| 1 | package Elive::Entity::Preload; | ||||||||||||||||||||||||||||||||
| 2 | 22 | ▶ | use warnings; use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | 22 | ▶ | use Mouse; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 22 | ▶ | use Mouse::Util::TypeConstraints; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 22 | extends 'Elive::Entity'; | |||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 22 | ▶ | use Elive::Util; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | 22 | ▶ | use SOAP::Lite; # contains SOAP::Data package | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | 22 | ▶ | use MIME::Types; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 22 | ▶ | use File::Basename qw{}; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 22 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 22 | __PACKAGE__->entity_name('Preload'); | |||||||||||||||||||||||||||||||
| 18 | 22 | __PACKAGE__->collection_name('Preloads'); | |||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 22 | has 'preloadId' => (is => 'rw', isa => 'Int', required => 1); | |||||||||||||||||||||||||||||||
| 21 | 22 | __PACKAGE__->primary_key('preloadId'); | |||||||||||||||||||||||||||||||
| 22 | 22 | __PACKAGE__->params( | |||||||||||||||||||||||||||||||
| 23 | meetingId => 'Str', | ||||||||||||||||||||||||||||||||
| 24 | fileName => 'Str', | ||||||||||||||||||||||||||||||||
| 25 | length => 'Int', | ||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||
| 27 | 22 | __PACKAGE__->_alias(key => 'preloadId'); | |||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 22 | enum enumPreloadTypes => qw(media whiteboard plan); | |||||||||||||||||||||||||||||||
| 30 | 22 | has 'type' => (is => 'rw', isa => 'enumPreloadTypes', required => 1, | |||||||||||||||||||||||||||||||
| 31 | documentation => 'preload type. media, whiteboard or plan', | ||||||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | 22 | has 'name' => (is => 'rw', isa => 'Str', required => 1, | |||||||||||||||||||||||||||||||
| 35 | documentation => 'preload name, e.g. "intro.wbd"', | ||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 22 | has 'mimeType' => (is => 'rw', isa => 'Str', required => 1, | |||||||||||||||||||||||||||||||
| 39 | documentation => 'The mimetype of the preload (e.g., video/quicktime).'); | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 22 | has 'ownerId' => (is => 'rw', isa => 'Str', required => 1, | |||||||||||||||||||||||||||||||
| 42 | documentation => 'preload owner (userId)', | ||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | 22 | has 'size' => (is => 'rw', isa => 'Int', required => 1, | |||||||||||||||||||||||||||||||
| 46 | documentation => 'The length of the preload in bytes', | ||||||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | 22 | has 'data' => (is => 'rw', isa => 'Str', | |||||||||||||||||||||||||||||||
| 50 | documentation => 'The contents of the preload.'); | ||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | 22 | has 'isProtected' => (is => 'rw', isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 53 | 22 | has 'isDataAvailable' => (is => 'rw', isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | sub BUILDARGS { | ||||||||||||||||||||||||||||||||
| 56 | 5 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=18 SCAR=44.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 57 | 5 | my $spec = shift; | |||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | 5 | my %args; | |||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | 5 | ▶ | if ($spec && ! ref($spec) ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$spec and not ref $spec
MC/DC0%0/2
$spec and not ref $spec
$spec
not ref $spec
Truth table33%1/3
A and not(B)
A= $specB= not ref $spec
| |||||||||||||||||||||||||||||||||
| 62 | # | ||||||||||||||||||||||||||||||||
| 63 | # Assume a single string arguments represents the local path of a file | ||||||||||||||||||||||||||||||||
| 64 | # to be uploaded. | ||||||||||||||||||||||||||||||||
| 65 | # | ||||||||||||||||||||||||||||||||
| 66 | 0 | my $preload_path = $spec; | |||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | open ( my $fh, '<', $preload_path) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 69 | or die "unable to open preload file $preload_path"; | ||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | 0 | binmode $fh; | |||||||||||||||||||||||||||||||
| 72 | 0 | my $content = do {local $/; <$fh>}; | |||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | 0 | close $fh; | |||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | die "upload file is empty: $preload_path" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 77 | unless length $content; | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | 0 | %args = ( | |||||||||||||||||||||||||||||||
| 80 | fileName => $preload_path, | ||||||||||||||||||||||||||||||||
| 81 | data => $content, | ||||||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||
| 84 | elsif (Elive::Util::_reftype($spec) eq 'HASH') { | ||||||||||||||||||||||||||||||||
| 85 | 5 | %args = %$spec; | |||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||
| 87 | else { | ||||||||||||||||||||||||||||||||
| 88 | 0 | croak 'usage: '.$class.'->new( filepath | {name => $filename, data => $binary_data, ...} )'; | |||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | 5 | ▶ | if ($args{data}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 92 | $args{size} ||= length( $args{data} ) | ||||||||||||||||||||||||||||||||
| 93 | 1 | ▶ | } | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$args{"size"} ||= length $args{"data"}
MC/DC0%0/2
$args{"size"} ||= length $args{"data"}
$args{"size"}
length $args{"data"}
Truth table33%1/3
A ||= B
A= $args{"size"}B= length $args{"data"}
| |||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | 5 | ▶ | if (defined $args{fileName} && length $args{fileName}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $args{"fileName"} and length $args{"fileName"}
MC/DC0%0/2
defined $args{"fileName"} and length $args{"fileName"}
defined $args{"fileName"}
length $args{"fileName"}
Truth table33%1/3
A and B
A= defined $args{"fileName"}B= length $args{"fileName"}
| |||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | $args{name} ||= File::Basename::basename( $args{fileName} ); | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$args{"name"} ||= File::Basename::basename($args{"fileName"})
MC/DC0%0/2
$args{"name"} ||= File::Basename::basename($args{"fileName"})
$args{"name"}
File::Basename::basename($args{"fileName"})
Truth table0%0/3
A ||= B
A= $args{"name"}B= File::Basename::basename($args{"fileName"})
| |||||||||||||||||||||||||||||||||
| 97 | croak "unable to determine a basename for preload path: $args{fileName}" | ||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | unless length $args{name}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||
| 101 | die "unable to determine file name" | ||||||||||||||||||||||||||||||||
| 102 | 5 | ▶ | unless defined $args{name} && length $args{name}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $args{"name"} and length $args{"name"}
MC/DC0%0/2
defined $args{"name"} and length $args{"name"}
defined $args{"name"}
length $args{"name"}
Truth table33%1/3
A and B
A= defined $args{"name"}B= length $args{"name"}
| |||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | 5 | ▶ | $args{mimeType} ||= $class->_guess_mimetype($args{name}); | ||||||||||||||||||||||||||||||
|
Condition66%2/3
$args{"mimeType"} ||= $class->_guess_mimetype($args{"name"})
MC/DC0%0/2
$args{"mimeType"} ||= $class->_guess_mimetype($args{"name"})
$args{"mimeType"}
$class->_guess_mimetype($args{"name"})
Truth table66%2/3
A ||= B
A= $args{"mimeType"}B= $class->_guess_mimetype($args{"name"})
| |||||||||||||||||||||||||||||||||
| 105 | $args{type} ||= ($args{name} =~ m{\.wb[pd]$}ix ? 'whiteboard' | ||||||||||||||||||||||||||||||||
| 106 | 5 | ▶ | : $args{name} =~ m{\.elpx?$}ix ? 'plan' | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$args{"type"} ||= $args{"name"} =~ /\.wb[pd]$/xi ? "whiteboard" : ($args{"name"} =~ /\.elpx?$/xi ? "plan" : "media")
MC/DC0%0/2
$args{"type"} ||= $args{"name"} =~ /\.wb[pd]$/xi ? "whiteboard" : ($args{"name"} =~ /\.elpx?$/xi ? "plan" : "media")
$args{"type"}
$args{"name"} =~ /\.wb[pd]$/xi ? "whiteboard" : ($args{"name"} =~ /\.elpx?$/xi ? "plan" : "media")
Truth table66%2/3
A ||= B
A= $args{"type"}B= $args{"name"} =~ /\.wb[pd]$/xi ? "whiteboard" : ($args{"name"} =~ /\.elpx?$/xi ? "plan" : "media")
| |||||||||||||||||||||||||||||||||
| 107 | : 'media'); | ||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | 5 | return \%args; | |||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||
| 112 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||
| 114 | Elive::Entity::Preload - Elluminate Preload instance class | ||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||
| 116 | =head2 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | This is the entity class for meeting preloads. | ||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||
| 120 | my $preloads = Elive::Entity::Preload->list( | ||||||||||||||||||||||||||||||||
| 121 | filter => 'mimeType=application/x-shockwave-flash', | ||||||||||||||||||||||||||||||||
| 122 | ); | ||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | my $preload = Elive::Entity::Preload->retrieve($preload_id); | ||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||
| 126 | my $type = $preload->type; | ||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | There are three possible types of preloads: media, plan and whiteboard. | ||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | =cut | ||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||
| 132 | =head1 METHODS | ||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||
| 134 | =cut | ||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | =head2 upload | ||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||
| 138 | # | ||||||||||||||||||||||||||||||||
| 139 | # upload from a file | ||||||||||||||||||||||||||||||||
| 140 | # | ||||||||||||||||||||||||||||||||
| 141 | my $preload1 = Elive::Entity::Preload->upload('mypreloads/intro.wbd'); | ||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||
| 143 | # | ||||||||||||||||||||||||||||||||
| 144 | # upload in-memory data | ||||||||||||||||||||||||||||||||
| 145 | # | ||||||||||||||||||||||||||||||||
| 146 | my $preload2 = Elive::Entity::Preload->upload( | ||||||||||||||||||||||||||||||||
| 147 | { | ||||||||||||||||||||||||||||||||
| 148 | type => 'whiteboard', | ||||||||||||||||||||||||||||||||
| 149 | name => 'introduction.wbd', | ||||||||||||||||||||||||||||||||
| 150 | ownerId => 357147617360, | ||||||||||||||||||||||||||||||||
| 151 | data => $binary_data, | ||||||||||||||||||||||||||||||||
| 152 | }, | ||||||||||||||||||||||||||||||||
| 153 | ); | ||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||
| 155 | Upload data from a client and create a preload. If a C<mimeType> is not | ||||||||||||||||||||||||||||||||
| 156 | supplied, it will be guessed from the C<name> extension, using | ||||||||||||||||||||||||||||||||
| 157 | L<MIME::Types>. | ||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | =cut | ||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | sub upload { | ||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | my ($class, $spec, %opt) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
upload: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | my $connection = $opt{connection} || $class->connection | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{'connection'} || $class->connection
MC/DC0%0/2
$opt{'connection'} || $class->connection
$opt{'connection'}
$class->connection
Truth table0%0/3
A || B
A= $opt{'connection'}B= $class->connection
| |||||||||||||||||||||||||||||||||
| 165 | or die "not connected"; | ||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||
| 167 | 0 | my $insert_data = $class->BUILDARGS( $spec ); | |||||||||||||||||||||||||||||||
| 168 | 0 | my $content = delete $insert_data->{data}; | |||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | $insert_data->{ownerId} ||= $connection->login->userId; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$insert_data->{"ownerId"} ||= $connection->login->userId
MC/DC0%0/2
$insert_data->{"ownerId"} ||= $connection->login->userId
$insert_data->{"ownerId"}
$connection->login->userId
Truth table0%0/3
A ||= B
A= $insert_data->{"ownerId"}B= $connection->login->userId
| |||||||||||||||||||||||||||||||||
| 170 | # | ||||||||||||||||||||||||||||||||
| 171 | # 1. create initial record | ||||||||||||||||||||||||||||||||
| 172 | # | ||||||||||||||||||||||||||||||||
| 173 | 0 | my $self = $class->insert($insert_data, %opt); | |||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if ($self->size && $content) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->size and $content
MC/DC0%0/2
$self->size and $content
$self->size
$content
Truth table0%0/3
A and B
A= $self->sizeB= $content
| |||||||||||||||||||||||||||||||||
| 176 | # | ||||||||||||||||||||||||||||||||
| 177 | # 2. Now upload data to it | ||||||||||||||||||||||||||||||||
| 178 | # | ||||||||||||||||||||||||||||||||
| 179 | my $som = $connection->call('streamPreload', | ||||||||||||||||||||||||||||||||
| 180 | 0 | %{ $self->_freeze( | |||||||||||||||||||||||||||||||
| 181 | {preloadId => $self->preloadId, | ||||||||||||||||||||||||||||||||
| 182 | length => $self->size, | ||||||||||||||||||||||||||||||||
| 183 | })}, | ||||||||||||||||||||||||||||||||
| 184 | stream => (SOAP::Data | ||||||||||||||||||||||||||||||||
| 185 | ->type('hexBinary') | ||||||||||||||||||||||||||||||||
| 186 | ->value($content)), | ||||||||||||||||||||||||||||||||
| 187 | ); | ||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||
| 189 | 0 | $connection->_check_for_errors($som); | |||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||
| 192 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||
| 195 | =head2 download | ||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||
| 197 | my $preload = Elive::Entity::Preload->retrieve($preload_id); | ||||||||||||||||||||||||||||||||
| 198 | my $binary_data = $preload->download; | ||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||
| 200 | Download preload data. | ||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||
| 202 | =cut | ||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||
| 204 | sub download { | ||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | my ($self, %opt) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
download: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | my $preload_id = $opt{preload_id} ||= $self->preloadId; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$opt{"preload_id"} ||= $self->preloadId
MC/DC0%0/2
$opt{"preload_id"} ||= $self->preloadId
$opt{"preload_id"}
$self->preloadId
Truth table0%0/3
A ||= B
A= $opt{"preload_id"}B= $self->preloadId
| |||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | die "unable to get a preload_id" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 210 | unless $preload_id; | ||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | my $connection = $opt{connection} || $self->connection | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{'connection'} || $self->connection
MC/DC0%0/2
$opt{'connection'} || $self->connection
$opt{'connection'}
$self->connection
Truth table0%0/3
A || B
A= $opt{'connection'}B= $self->connection
| |||||||||||||||||||||||||||||||||
| 213 | or die "not connected"; | ||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||
| 215 | my $som = $connection->call('getPreloadStream', | ||||||||||||||||||||||||||||||||
| 216 | 0 | %{$self->_freeze({preloadId => $preload_id})} | |||||||||||||||||||||||||||||||
| 217 | ); | ||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||
| 219 | 0 | my $results = $self->_get_results($som, $connection); | |||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | return Elive::Util::_hex_decode($results->[0]) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 222 | if $results->[0]; | ||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||
| 224 | 0 | return; | |||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||
| 227 | =head2 import_from_server | ||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||
| 229 | my $preload1 = Elive::Entity::Preload->import_from_server( | ||||||||||||||||||||||||||||||||
| 230 | { | ||||||||||||||||||||||||||||||||
| 231 | type => 'whiteboard', | ||||||||||||||||||||||||||||||||
| 232 | name => 'introduction.wbd', | ||||||||||||||||||||||||||||||||
| 233 | ownerId => 357147617360, | ||||||||||||||||||||||||||||||||
| 234 | fileName => $path_on_server | ||||||||||||||||||||||||||||||||
| 235 | }, | ||||||||||||||||||||||||||||||||
| 236 | ); | ||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||
| 238 | Create a preload from a file that is already present on the server's | ||||||||||||||||||||||||||||||||
| 239 | file-system. If a C<mimeType> is not supplied, it will be guessed from | ||||||||||||||||||||||||||||||||
| 240 | the C<name> or C<fileName> extension using L<MIME::Types>. | ||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||
| 242 | =cut | ||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||
| 244 | sub import_from_server { | ||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | my ($class, $spec, %opt) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
import_from_server: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | $spec = {fileName => $spec} if defined $spec && !ref $spec; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $spec and not ref $spec
MC/DC0%0/2
defined $spec and not ref $spec
defined $spec
not ref $spec
Truth table0%0/3
A and not(B)
A= defined $specB= not ref $spec
| |||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||
| 249 | 0 | my $insert_data = $class->BUILDARGS($spec); | |||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||
| 251 | die "missing required parameter: fileName" | ||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | unless $insert_data->{fileName}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | $insert_data->{ownerId} ||= do { | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$insert_data->{"ownerId"} ||= do {
my $connection = $opt{"connection"} || $class->connection or die "not connected";
$connection->login->userId
}
MC/DC0%0/2
$insert_data->{"ownerId"} ||= do {
my $connection = $opt{"connection"} || $class->connection or die "not connected";
$connection->login->userId
}
$insert_data->{"ownerId"}
do {
my $connection = $opt{"connection"} || $class->connection or die "not connected";
$connection->login->userId
}
Truth table0%0/3
A ||= B
A= $insert_data->{"ownerId"}B= do {
my $connection = $opt{"connection"} || $class->connection or die "not connected";
$connection->login->userId
}
| |||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | my $connection = $opt{connection} || $class->connection | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{'connection'} || $class->connection
MC/DC0%0/2
$opt{'connection'} || $class->connection
$opt{'connection'}
$class->connection
Truth table0%0/3
A || B
A= $opt{'connection'}B= $class->connection
| |||||||||||||||||||||||||||||||||
| 256 | or die "not connected"; | ||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||
| 258 | 0 | $connection->login->userId; | |||||||||||||||||||||||||||||||
| 259 | }; | ||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | $opt{command} ||= 'importPreload'; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$opt{"command"} ||= "importPreload"
MC/DC0%0/1
$opt{"command"} ||= "importPreload"
$opt{"command"}
Truth table0%0/2
A
A= $opt{"command"}
| |||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||
| 263 | 0 | return $class->insert($insert_data, %opt); | |||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||
| 266 | =head2 list_meeting_preloads | ||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||
| 268 | my $preloads = Elive::Entity::Preload->list_meeting_preloads($meeting_id); | ||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||
| 270 | Returns a list of preloads associated with the given meeting-Id or meeting | ||||||||||||||||||||||||||||||||
| 271 | object. | ||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||
| 273 | =cut | ||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||
| 275 | sub list_meeting_preloads { | ||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | my ($self, $meeting_id, %opt) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
list_meeting_preloads: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | die 'usage: $preload_obj->list_meeting_preloads($meeting)' | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 279 | unless $meeting_id; | ||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | $opt{command} ||= 'listMeetingPreloads'; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$opt{"command"} ||= "listMeetingPreloads"
MC/DC0%0/1
$opt{"command"} ||= "listMeetingPreloads"
$opt{"command"}
Truth table0%0/2
A
A= $opt{"command"}
| |||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||
| 283 | 0 | return $self->_fetch({meetingId => $meeting_id}, %opt); | |||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||
| 286 | =head2 list | ||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||
| 288 | my $all_preloads = Elive::Entity::Preload->list(); | ||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||
| 290 | Lists all known preloads. | ||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||
| 292 | =cut | ||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||
| 294 | sub _thaw { | ||||||||||||||||||||||||||||||||
| 295 | 2 | ▶ | my ($class, $db_data, %opt) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
_thaw: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||
| 297 | 2 | my $db_thawed = $class->SUPER::_thaw($db_data, %opt); | |||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||
| 299 | 2 | for (grep {defined} $db_thawed->{type}) { | |||||||||||||||||||||||||||||||
| 300 | # | ||||||||||||||||||||||||||||||||
| 301 | # Just to pass type constraints | ||||||||||||||||||||||||||||||||
| 302 | # | ||||||||||||||||||||||||||||||||
| 303 | 2 | $_ = lc($_); | |||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||
| 305 | 2 | ▶ | unless (m{^media|whiteboard|plan$}x) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 306 | 1 | Carp::carp "ignoring unknown media type: $_"; | |||||||||||||||||||||||||||||||
| 307 | 1 | delete $db_thawed->{type}; | |||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||
| 311 | 2 | return $db_thawed; | |||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||
| 314 | =head2 update | ||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||
| 316 | The update method is not available for preloads. | ||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||
| 318 | =cut | ||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | sub update {return shift->_not_available} | ||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||
| 322 | sub _guess_mimetype { | ||||||||||||||||||||||||||||||||
| 323 | 1 | ▶ | my ($class, $filename) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
_guess_mimetype: called CC=6 SCAR=19.4
| |||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||
| 325 | 1 | my $mime_type; | |||||||||||||||||||||||||||||||
| 326 | my $guess; | ||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||
| 328 | 1 | ▶ | unless ($filename =~ m{\.elpx?}x) { # plan | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 329 | 1 | ▶ | our $mime_types ||= MIME::Types->new; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
our $mime_types ||= "MIME::Types"->new
MC/DC0%0/2
our $mime_types ||= "MIME::Types"->new
our $mime_types
"MIME::Types"->new
Truth table33%1/3
A ||= B
A= our $mime_typesB= "MIME::Types"->new
| |||||||||||||||||||||||||||||||||
| 330 | 1 | $mime_type = $mime_types->mimeTypeOf($filename); | |||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||
| 332 | 1 | ▶ | $guess = $mime_type->type | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 333 | if $mime_type; | ||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||
| 336 | 1 | ▶ | $guess ||= 'application/octet-stream'; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$guess ||= "application/octet-stream"
MC/DC0%0/1
$guess ||= "application/octet-stream"
$guess
Truth table50%1/2
A
A= $guess
| |||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||
| 338 | # untaint | ||||||||||||||||||||||||||||||||
| 339 | 1 | ▶ | $guess = $1 | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 340 | if $guess =~ /([[:print:]]+)/; | ||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||
| 342 | 1 | return $guess; | |||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||
| 345 | sub _readback_check { | ||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | my ($class, $update_ref, $rows, @args) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
_readback_check: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||
| 348 | # | ||||||||||||||||||||||||||||||||
| 349 | # Elluminate 10.0 discards the file extension for whiteboard preloads; | ||||||||||||||||||||||||||||||||
| 350 | # bypass check on 'name'. | ||||||||||||||||||||||||||||||||
| 351 | # | ||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||
| 353 | 0 | my %updates = %{ $update_ref }; | |||||||||||||||||||||||||||||||
| 354 | 0 | delete $updates{name}; | |||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||
| 356 | 0 | return $class->SUPER::_readback_check(\%updates, $rows, @args, case_insensitive => 1); | |||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||
| 359 | =head1 BUGS AND LIMITATIONS | ||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||
| 361 | =over 4 | ||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||
| 363 | =item * Under Elluminate 9.6.0 and LDAP, you may need to arbitrarily add a 'DomN:' | ||||||||||||||||||||||||||||||||
| 364 | prefix to the owner ID, when creating or updating a meeting. | ||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||
| 366 | $preload->ownerId('Dom1:freddy'); | ||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||
| 368 | =item * Elluminate 10.0 strips the file extension from the filename when | ||||||||||||||||||||||||||||||||
| 369 | whiteboard files are saved or uploaded (C<introduction.wbd> => C<introduction>). | ||||||||||||||||||||||||||||||||
| 370 | However, if the file lacks an extension to begin with, the request crashes with | ||||||||||||||||||||||||||||||||
| 371 | the confusing error message: C<"string index out of range: -1">. | ||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||
| 373 | =item * As of ELM 3.3.5, The C<filter> option appears to have no affect when passed to the C<list()> method. | ||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||
| 375 | =back | ||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||
| 377 | =cut | ||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||
| 379 | 22 | 1; | |||||||||||||||||||||||||||||||