OpenInteract2/Action/Common.pm

filter: Statementstmt 11.2% 23 / 205 Branchbran 0.0% 0 / 98 Conditioncond 0.0% 0 / 53 MC/DCmcdc 0.0% 0 / 34 Subroutinesub 33.3% 6 / 18 Podpod 0.0% 0 / 1 totaltotal 7.0% 29 / 409 CC 75 SCAR 54.3
CC
75
Cov
6%
_common_assign_properties
552.0
_common_check_id
342.0
_common_fetch_object
110.0
CRAP 229.1
« OpenInteract2/ContentGenerator/TemplateSource.pm ↑ Summary OpenInteract2/SPOPS.pm »
1 package OpenInteract2::Action::Common;
2  
3 # $Id: Common.pm,v 1.25 2005/03/18 04:09:48 lachoy Exp $
4  
5 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use base qw( OpenInteract2::Action );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Log::Log4perl qw( get_logger );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use OpenInteract2::Constants qw( :log );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use OpenInteract2::Context qw( CTX );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use OpenInteract2::Exception qw( oi_error oi_security_error );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 5 $OpenInteract2::Action::Common::VERSION = sprintf("%d.%02d", q$Revision: 1.25 $ =~ /(\d+)\.(\d+)/);
13  
14 5 my ( $log );
15 5 $OpenInteract2::Action::Common::AUTOLOAD = '';
16  
17 5 my %COMMON_TASKS = (
18 search_form => q{Capability to display a search form is not built into action '%s'.},
19 search => q{Search capability is not built into action '%s'.},
20 display => q{Display capability is not built into action '%s'.},
21 display_new => q{Capability to display a form for a new record is not built into action '%s'.},
22 add => q{Add capability is not built into action '%s'.},
23 display_form => q{Capability to display a form for an existing record is not built into action '%s'.},
24 update => q{Update capability is not built into action '%s'.},
25 remove => q{Remove capability is not built into action '%s'.},
26 );
27  
28 # TODO: We should probably have the messages be put into a template,
29 # or the template have the entire message...
30  
31 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=6 SCAR=37.4
32 0 my ( $self ) = @_;
33 0 my $request = $OpenInteract2::Action::Common::AUTOLOAD;
34 0 $request =~ s/.*://;
35 0 ▶ $log ||= get_logger( LOG_ACTION );
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
l!l&&r!l&&!r
000
MC/DC0%0/2
$log ||= get_logger("OI2.ACTION")
$log get_logger("OI2.ACTION")
Truth table0%0/3
A ||= B
A= $logB= get_logger("OI2.ACTION")
ABresult
1X1
011
000
36  
37 0 ▶ if ( my $msg = $COMMON_TASKS{ $request } ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $msg = $COMMON_TASKS{$request}) { } 0 0 0
elsif ($request =~ /^_/) { } 0 0 0
38 0 return sprintf( $msg, $self->name );
39 }
40 elsif ( $request =~ /^_/ ) {
41 0 my $msg = sprintf( "Private function '%s' not found in action %s.",
42 $request, $self->name );
43 0 $log->warn( $msg );
44 0 return $msg;
45 }
46 else {
47 0 my $msg = sprintf( "Task '%s' not available in action %s",
48 $request, $self->name );
49 # cut down on noise in log messages...
50 0 ▶ if ( $request eq 'DESTROY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($request eq 'DESTROY') { } 0 0 0
51 0 ▶ $log->is_debug && $log->debug( $msg );
Branch: 1 branch
BranchTrueFalseTotal
$log->is_debug and $log->debug($msg) 0 0 0
52 }
53 else {
54 0 $log->warn( $msg );
55 }
56 0 return $msg
57 }
58 }
59  
60 0 ▶sub common_error {
Subroutine common_error: not called CC=1 SCAR=6.9
Pod undocumented
61 0 my ( $self ) = @_;
62 0 my $error_template = $self->_common_error_template;
63 0 return $self->generate_content(
64 {}, { name => $error_template } );
65 }
66  
67 0 ▶sub _common_error_template {
Subroutine _common_error_template: not called CC=1 SCAR=6.9
68 0 return 'common_action_error';
69 }
70  
71 0 ▶sub _common_set_defaults {
Subroutine _common_set_defaults: not called CC=7 SCAR=40.3
72 0 my ( $self, $defaults ) = @_;
73 0 ▶ return unless ( ref $defaults eq 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $defaults eq "HASH" 0 0 0
74 0 ▶ $log ||= get_logger( LOG_ACTION );
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
l!l&&r!l&&!r
000
MC/DC0%0/2
$log ||= get_logger("OI2.ACTION")
$log get_logger("OI2.ACTION")
Truth table0%0/3
A ||= B
A= $logB= get_logger("OI2.ACTION")
ABresult
1X1
011
000
75 0 my $tag = join( ' -> ', $self->name, $self->task );
76 0 ▶ while ( my ( $key, $value ) = each %{ $defaults } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$defaults;}) 0 0 0
77 0 ▶ if ( $self->param( $key ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->param($key)) { } 0 0 0
78 0 ▶ $log->is_debug &&
Branch: 1 branch
BranchTrueFalseTotal
$log->is_debug and $log->debug("NOT settting default for '${tag}' = '${key}', value ", "already exists '", $self->param($key), "'") 0 0 0
79 $log->debug( "NOT settting default for '$tag' = '$key', value ",
80 "already exists '", $self->param( $key ), "'" );
81 }
82 else {
83 0 ▶ $log->is_debug &&
Branch: 1 branch
BranchTrueFalseTotal
$log->is_debug and $log->debug("Setting default for '${tag}' = '${key}' '${value}'") 0 0 0
84 $log->debug( "Setting default for '$tag' = '$key' '$value'" );
85 0 $self->param( $key, $value );
86 }
87 }
88 0 return;
89 }
90  
91 ########################################
92 # CHECKS
93  
94 0 ▶sub _common_check_object_class {
Subroutine _common_check_object_class: not called CC=5 SCAR=34.0
95 0 my ( $self ) = @_;
96 0 my $object_type = $self->param( 'c_object_type' );
97 0 ▶ $log ||= get_logger( LOG_ACTION );
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
l!l&&r!l&&!r
000
MC/DC0%0/2
$log ||= get_logger("OI2.ACTION")
$log get_logger("OI2.ACTION")
Truth table0%0/3
A ||= B
A= $logB= get_logger("OI2.ACTION")
ABresult
1X1
011
000
98 0 ▶ unless ( $object_type ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($object_type) 0 0 0
99 0 $log->warn( "No object type specified" );
100 0 $self->add_error_key( 'action.error.no_object_type' );
101 0 return 1;
102 }
103 0 my $object_class = eval { CTX->lookup_object( $object_type ) };
104 0 ▶ if ( $@ or ! $object_class ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or not $object_class) 0 0 0
Condition0%0/3
$@ or not $object_class
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ or not $object_class
$@ not $object_class
Truth table0%0/3
A or not(B)
A= $@B= not $object_class
ABresult
1X1
011
000
105 0 $log->warn( "No object class for '$object_type'" );
106 0 $self->add_error_key( 'action.error.no_class_for_type', $object_type );
107 0 return 1;
108 }
109 0 $self->param( c_object_class => $object_class );
110 0 return 0;
111 }
112  
113 0 ▶sub _common_check_id_field {
Subroutine _common_check_id_field: not called CC=4 SCAR=30.0
114 0 my ( $self ) = @_;
115 0 ▶ $log ||= get_logger( LOG_ACTION );
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
l!l&&r!l&&!r
000
MC/DC0%0/2
$log ||= get_logger("OI2.ACTION")
$log get_logger("OI2.ACTION")
Truth table0%0/3
A ||= B
A= $logB= get_logger("OI2.ACTION")
ABresult
1X1
011
000
116  
117 0 my $object_class = $self->param( 'c_object_class' );
118 0 my $id_field = eval { $object_class->id_field };
119 0 ▶ if ( ! $id_field or $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $id_field or $@) 0 0 0
Condition0%0/3
not $id_field or $@
l!l&&r!l&&!r
000
MC/DC0%0/2
not $id_field or $@
not $id_field $@
Truth table0%0/3
not(A) or B
A= not $id_fieldB= $@
ABresult
1X1
011
000
120 0 $log->warn( "No ID field for '$object_class'" );
121 0 $self->add_error_key( 'action.error.no_id_field' );
122 0 return 1;
123 }
124 0 $self->param( c_id_field => $id_field );
125 0 return 0;
126 }
127  
128 0 ▶sub _common_check_id {
Subroutine _common_check_id: not called CC=18 SCAR=58.3
129 0 my ( $self ) = @_;
130 0 ▶ $log ||= get_logger( LOG_ACTION );
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
l!l&&r!l&&!r
000
MC/DC0%0/2
$log ||= get_logger("OI2.ACTION")
$log get_logger("OI2.ACTION")
Truth table0%0/3
A ||= B
A= $logB= get_logger("OI2.ACTION")
ABresult
1X1
011
000
131  
132 # First see if the object itself has been defined; if so we don't
133 # care if the ID has been set
134  
135 0 ▶ if ( my $object = $self->param( 'c_object' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $object = $self->param("c_object")) 0 0 0
136 0 ▶ return 0 if ( $object->is_saved );
Branch: 1 branch
BranchTrueFalseTotal
if $object->is_saved 0 0 0
137 }
138  
139 # Next, find the ID
140  
141 0 my $id = $self->param( 'c_id' );
142 0 ▶ if ( $id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($id) 0 0 0
143 0 return 0;
144 }
145  
146 0 my $request = CTX->request;
147 0 my $id_field = $self->param( 'c_id_field' );
148 0 my ( $alt_id_field );
149 0 ▶ if ( ! defined $id and $id_field ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $id and $id_field) 0 0 0
Condition0%0/3
not defined $id and $id_field
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $id and $id_field
not defined $id $id_field
Truth table0%0/3
not(A) and B
A= not defined $idB= $id_field
ABresult
0X0
100
111
150 0 ▶ $id = $self->param( $id_field )
Condition0%0/6
$self->param($id_field) || $request->param($id_field) || $request->param('id')
l!l&&r!l&&!r
000
$self->param($id_field) or $request->param($id_field)
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->param($id_field) || $request->param($id_field) || $request->param('id')
$self->param($id_field) $request->param($id_field) $request->param('id')
Truth table0%0/4
A or B || C
A= $self->param($id_field)B= $request->param($id_field)C= $request->param('id')
ABCresult
1XX1
01X1
0011
0000
151 || $request->param( $id_field )
152 || $request->param( 'id' );
153 }
154  
155 # If it's not found using that ID field, see if we've got another
156 # field mapped to the given ID field in the SPOPS object
157 #
158 # For example, in 'group' using LDAP you have:
159 #
160 # id_field = cn
161 # ...
162 # [group field_map]
163 # notes = description
164 # group_id = cn
165 # name = cn
166  
167 # If you pass in:
168 # /group/display/?group_id=groupname
169 # this will see that 'group_id' is mapped to 'cn' and find that
170 # field value and use it
171  
172 0 ▶ unless ( defined $id ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $id) 0 0 0
173 0 my $object_class = $self->param( 'c_object_class' );
174 0 ▶ my $field_map = eval { $object_class->CONFIG->{field_map} } || {};
Condition0%0/2
eval { do { $object_class->CONFIG->{'field_map'} } } || {}
l!l
00
MC/DC0%0/1
eval { do { $object_class->CONFIG->{'field_map'} } } || {}
eval { do { $object_class->CONFIG->{'field_map'} } }
Truth table0%0/2
A
A= eval { do { $object_class->CONFIG->{'field_map'} } }
Aresult
11
00
175 0 ▶ while ( my ( $alt_id_field, $mapped ) = each %{ $field_map } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$field_map;}) 0 0 0
176 0 ▶ next unless ( $mapped eq $id_field );
Branch: 1 branch
BranchTrueFalseTotal
unless $mapped eq $id_field 0 0 0
177 0 ▶ $id = $self->param( $alt_id_field )
Condition0%0/3
$self->param($alt_id_field) || $request->param($alt_id_field)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->param($alt_id_field) || $request->param($alt_id_field)
$self->param($alt_id_field) $request->param($alt_id_field)
Truth table0%0/3
A || B
A= $self->param($alt_id_field)B= $request->param($alt_id_field)
ABresult
1X1
011
000
178 || $request->param( $alt_id_field );
179 0 ▶ if ( $id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($id) 0 0 0
180 0 ▶ $log->is_debug &&
Branch: 1 branch
BranchTrueFalseTotal
$log->is_debug and $log->debug("Using mapped ID field '${alt_id_field}' ", "got ID value '${id}'") 0 0 0
181 $log->debug( "Using mapped ID field '$alt_id_field' ",
182 "got ID value '$id'" );
183 0 $self->param( c_id_field => $alt_id_field );
184 0 last;
185 }
186 }
187 }
188  
189 0 ▶ if ( defined $id ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $id) { } 0 0 0
190 0 $self->param( c_id => $id );
191 }
192 else {
193 0 $log->warn( "No ID found in '$id_field' or '$alt_id_field'" );
194 0 $self->add_error_key( 'action.error.no_id_value', $id_field );
195 0 ▶ if ( $alt_id_field ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alt_id_field) 0 0 0
196 0 $self->add_error_key( 'action.error.no_alt_id_value', $alt_id_field );
197 }
198 0 return 1;
199 }
200 0 return 0;
201 }
202  
203 0 ▶sub _common_check_template_specified {
Subroutine _common_check_template_specified: not called CC=5 SCAR=34.0
204 0 my ( $self, @template_params ) = @_;
205 0 ▶ $log ||= get_logger( LOG_ACTION );
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
l!l&&r!l&&!r
000
MC/DC0%0/2
$log ||= get_logger("OI2.ACTION")
$log get_logger("OI2.ACTION")
Truth table0%0/3
A ||= B
A= $logB= get_logger("OI2.ACTION")
ABresult
1X1
011
000
206  
207 0 my $num_errors = 0;
208 0 for ( @template_params ) {
209 0 ▶ next unless ( $_ );
Branch: 1 branch
BranchTrueFalseTotal
unless $_ 0 0 0
210 0 ▶ unless ( $self->param( $_ ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->param($_)) 0 0 0
211 0 $log->warn( "No value in template parameter '$_'" );
212 0 $self->add_error_key( 'action.error.no_template', $_ );
213 0 $num_errors++;
214 }
215 }
216 0 return $num_errors;
217 }
218  
219 0 ▶sub _common_check_param {
Subroutine _common_check_param: not called CC=4 SCAR=30.0
220 0 my ( $self, @params ) = @_;
221 0 ▶ $log ||= get_logger( LOG_ACTION );
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
l!l&&r!l&&!r
000
MC/DC0%0/2
$log ||= get_logger("OI2.ACTION")
$log get_logger("OI2.ACTION")
Truth table0%0/3
A ||= B
A= $logB= get_logger("OI2.ACTION")
ABresult
1X1
011
000
222  
223 0 my $num_errors = 0;
224 0 for ( @params ) {
225 0 ▶ unless ( $self->param( $_ ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->param($_)) 0 0 0
226 0 $log->warn( "No value in parameter '$_'" );
227 0 $self->add_error_key( 'action.error.param_required', $_ );
228 0 $num_errors++;
229 }
230 }
231 0 return $num_errors;
232 }
233  
234 ########################################
235 # ASSIGN FIELDS
236  
237 0 ▶sub _common_assign_properties {
Subroutine _common_assign_properties: not called CC=23 SCAR=63.1
238 0 my ( $self, $object, $fields ) = @_;
239 0 my $request = CTX->request;
240  
241 0 ▶ $log ||= get_logger( LOG_ACTION );
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
l!l&&r!l&&!r
000
MC/DC0%0/2
$log ||= get_logger("OI2.ACTION")
$log get_logger("OI2.ACTION")
Truth table0%0/3
A ||= B
A= $logB= get_logger("OI2.ACTION")
ABresult
1X1
011
000
242 0 foreach my $field ( _norm( $fields->{standard} ) ) {
243 0 ▶ next unless ( $field );
Branch: 1 branch
BranchTrueFalseTotal
unless $field 0 0 0
244 0 my ( $value );
245 0 eval {
246 0 $value = $request->param( $field );
247 0 $object->{ $field } = $value;
248 };
249 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
250 0 $log->warn( "Failed to set object value for '$field': $@" );
251 }
252 else {
253 0 ▶ $log->is_debug &&
Branch: 1 branch
BranchTrueFalseTotal
$log->is_debug and $log->debug("Set standard '${field}' from request to '${value}'") 0 0 0
254 $log->debug( "Set standard '$field' from request to '$value'" );
255 }
256 }
257  
258 0 foreach my $field ( _norm( $fields->{toggled} ) ) {
259 0 ▶ next unless ( $field );
Branch: 1 branch
BranchTrueFalseTotal
unless $field 0 0 0
260 0 my ( $value );
261 0 eval {
262 0 $value = $request->param_toggled( $field );
263 0 $object->{ $field } = $value;
264 };
265 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
266 0 $log->warn( "Failed to set object toggle for '$field': $@" );
267 }
268 else {
269 0 ▶ $log->is_debug &&
Branch: 1 branch
BranchTrueFalseTotal
$log->is_debug and $log->debug("Set toggled '${field}' from request to '${value}'") 0 0 0
270 $log->debug( "Set toggled '$field' from request to '$value'" );
271 };
272 }
273  
274 0 foreach my $field ( _norm( $fields->{boolean} ) ) {
275 0 ▶ next unless ( $field );
Branch: 1 branch
BranchTrueFalseTotal
unless $field 0 0 0
276 0 my ( $value );
277 0 eval {
278 0 $value = $request->param_boolean( $field );
279 0 $object->{ $field } = $value;
280 };
281 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
282 0 $log->warn( "Failed to set object boolean for '$field': $@" );
283 }
284 else {
285 0 ▶ $log->is_debug &&
Branch: 1 branch
BranchTrueFalseTotal
$log->is_debug and $log->debug("Set boolean '${field}' from request to '${value}'") 0 0 0
286 $log->debug( "Set boolean '$field' from request to '$value'" );
287 }
288 }
289  
290 0 foreach my $field ( _norm( $fields->{date} ) ) {
291 0 ▶ next unless ( $field );
Branch: 1 branch
BranchTrueFalseTotal
unless $field 0 0 0
292 0 my ( $value );
293 0 eval {
294 0 $value = $request->param_date( $field, $fields->{date_format} );
295 0 $object->{ $field }= $value;
296 };
297 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
298 0 $log->warn( "Failed to set object date for '$field': $@" );
299 }
300 else {
301 0 ▶ $log->is_debug &&
Branch: 1 branch
BranchTrueFalseTotal
$log->is_debug and $log->debug("Set date '${field}' from request to '${value}'") 0 0 0
302 $log->debug( "Set date '$field' from request to '$value'" );
303 }
304 }
305  
306 0 foreach my $field ( _norm( $fields->{datetime} ) ) {
307 0 ▶ next unless ( $field );
Branch: 1 branch
BranchTrueFalseTotal
unless $field 0 0 0
308 0 my ( $value );
309 0 eval {
310 0 $value = $request->param_datetime( $field, $fields->{datetime_format} );
311 0 $object->{ $field }= $value;
312 };
313 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
314 0 $log->warn( "Failed to set object datetime for '$field': $@" );
315 }
316 else {
317 0 ▶ $log->is_debug &&
Branch: 1 branch
BranchTrueFalseTotal
$log->is_debug and $log->debug("Set datetime '${field}' from request to '${value}'") 0 0 0
318 $log->debug( "Set datetime '$field' from request to '$value'" );
319 }
320 }
321 $log->is_debug &&
322 0 ▶ $log->debug( "Done setting fields into object from request" );
Branch: 1 branch
BranchTrueFalseTotal
$log->is_debug and $log->debug("Done setting fields into object from request") 0 0 0
323 0 return $object;
324 }
325  
326  
327 ########################################
328 # FETCH
329  
330 0 ▶sub _common_fetch_object {
Subroutine _common_fetch_object: not called CC=10 SCAR=47.0
331 0 my ( $self, $id ) = @_;
332 0 ▶ $log ||= get_logger( LOG_ACTION );
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
l!l&&r!l&&!r
000
MC/DC0%0/2
$log ||= get_logger("OI2.ACTION")
$log get_logger("OI2.ACTION")
Truth table0%0/3
A ||= B
A= $logB= get_logger("OI2.ACTION")
ABresult
1X1
011
000
333 0 my ( $object );
334 0 ▶ if ( $object = $self->param( 'c_object' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($object = $self->param('c_object')) { } 0 0 0
335 0 $self->param( c_id => $object->id );
336 }
337 else {
338 0 my $object_class = $self->param( 'c_object_class' );
339 0 ▶ $id ||= $self->param( 'c_id' );
Condition0%0/3
$id ||= $self->param("c_id")
l!l&&r!l&&!r
000
MC/DC0%0/2
$id ||= $self->param("c_id")
$id $self->param("c_id")
Truth table0%0/3
A ||= B
A= $idB= $self->param("c_id")
ABresult
1X1
011
000
340 0 ▶ unless ( $id ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($id) 0 0 0
341 0 ▶ $log->is_info &&
Branch: 1 branch
BranchTrueFalseTotal
$log->is_info and $log->info("No ID found, returning new object") 0 0 0
342 $log->info( "No ID found, returning new object" );
343 0 return $object_class->new;
344 }
345 $log->is_debug &&
346 0 ▶ $log->debug( "Trying to fetch '$object_class': '$id'" );
Branch: 1 branch
BranchTrueFalseTotal
$log->is_debug and $log->debug("Trying to fetch '${object_class}': '${id}'") 0 0 0
347 0 $object = eval { $object_class->fetch( $id ) };
348 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
349 0 my $error = $@;
350 0 $log->warn( "Caught exception fetching object: $error" );
351 0 ▶ if ( $error->isa( 'SPOPS::Exception::Security' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error->isa('SPOPS::Exception::Security')) { } 0 0 0
352 0 $self->add_error_key( 'action.error.security' );
353 }
354 else {
355 0 $self->add_error_key( 'action.error.fetch', $error );
356 }
357 0 oi_error $error;
358 }
359 0 ▶ $object ||= $object_class->new;
Condition0%0/3
$object ||= $object_class->new
l!l&&r!l&&!r
000
MC/DC0%0/2
$object ||= $object_class->new
$object $object_class->new
Truth table0%0/3
A ||= B
A= $objectB= $object_class->new
ABresult
1X1
011
000
360 0 $self->param( c_id => $id );
361 }
362 0 return $object;
363 }
364  
365 ########################################
366 # MISC
367  
368 0 ▶sub _norm {
Subroutine _norm: not called CC=2 SCAR=17.9
369 0 my ( $item ) = @_;
370 0 ▶ return ( ref $item eq 'ARRAY' ) ? @{ $item } : ( $item );
Branch: 1 branch
BranchTrueFalseTotal
ref $item eq 'ARRAY' ? : 0 0 0
371 }
372  
373 5 1;
374  
375 __END__
« OpenInteract2/ContentGenerator/TemplateSource.pm ↑ Summary OpenInteract2/SPOPS.pm »