| 1 | package OpenInteract2::Action; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # $Id: Action.pm,v 1.73 2005/03/17 14:57:56 sjn Exp $ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 87 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 87 | ▶ | use base qw( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | OpenInteract2::ParamContainer | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | Class::Accessor::Fast | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | Class::Observable | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | Class::Factory | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 87 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 87 | ▶ | use Log::Log4perl qw( get_logger ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 87 | ▶ | use OpenInteract2::Constants qw( :log :template ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 87 | ▶ | use OpenInteract2::Context qw( CTX ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 87 | ▶ | use OpenInteract2::Exception qw( oi_error oi_security_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 87 | ▶ | use OpenInteract2::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 87 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 87 | ▶ | use SPOPS::Secure qw( :level ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 87 | $OpenInteract2::Action::VERSION = sprintf("%d.%02d", q$Revision: 1.73 $ =~ /(\d+)\.(\d+)/); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 87 | my ( $log ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 87 | ▶ | use constant CACHE_CLASS_KEY => 'class_cache_track'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 87 | ▶ | use constant CACHE_ALL_KEY => '__ALL__'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # TODO: Set default action security from server configuration? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # This is what we set the action security level to when the action is | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # not secured. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 87 | ▶ | use constant DEFAULT_ACTION_SECURITY => SEC_LEVEL_WRITE; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # ACCESSORS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # See 'PROPERTIES' section below for other properties used. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 87 | my %PROPS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | controller => 'OI2::Controller object: assigned at each request', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | content_generator => 'OI2::ContentGenerator object: assigned at each request', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | package_name => 'Name of package that contains this action', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | action_type => 'Parent action type; these are declared in the server configuration under "action_type"', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | class => 'Class associated with action', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | method => 'Method that always gets called for action no matter what task is assigned.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | message_name => 'Key to use for messages deposited in request (default is action name)', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | task => 'Method to run when execute() called', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | task_default => 'Task to use if none specified in URL/invocation', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | task_valid => 'List of valid tasks available; if specified only these may be called', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | task_invalid => 'List of tasks which cannot be called (also, no task with a leading "_" may be called)', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | security_level => 'Security level found for this action + task invocation', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | security_required => 'Security level required for this action + task invocation', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | security => 'Configured security levels', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | url_alt => 'Alternate URLs that can be used to lookup this action', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | url_none => 'Flag to indicate that this action cannot be looked up by URL (yes/no)', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | template_source => 'Template(s) to use to generate task content; can be specified per-task', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | cache_param => 'Parameters to use when caching contnent', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | url_additional => 'Parameter names to which additional URL parameters get assigned; may be segmented by task', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 87 | __PACKAGE__->mk_accessors( keys %PROPS ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # Used to track classes, types, methods and security info | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 87 | my %ACTION_TASK_METHODS = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 87 | my %ACTION_SECURITY = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # Class method, called when server starts up | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub init_at_startup { return; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_at_startup: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # CONSTRUCTOR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # XXX: Document/change REQUEST_URL | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=15 SCAR=41.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | my ( $class, $item, $props ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | ▶ | $props ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$props ||= {}
MC/DC100%1/1
$props ||= {}
$props
Truth table100%2/2
A
A= $props
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | my ( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | ▶ | $log ||= get_logger( LOG_ACTION ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$log ||= get_logger("OI2.ACTION")
MC/DC0%0/2
$log ||= get_logger("OI2.ACTION")
$log
get_logger("OI2.ACTION")
Truth table66%2/3
A ||= B
A= $logB= get_logger("OI2.ACTION")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # Pass in another action... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | ▶ | if ( blessed( $item ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $log->warn( "Please modify ", join( ' | ', caller ), " ", | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | "to call 'clone()' instead of passing an action ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | "object to 'new()'" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | return $item->clone( $props ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # ...or action info | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | elsif ( ref $item eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | $log->debug( "Creating new action from action info with name ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | "'$item->{name}'" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $self = $class->_create_from_config( $item ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | # ...or a name | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | elsif ( $item ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | $log->debug( "Creating new action from name '$item'" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # This will throw an error if the action cannot be found | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $action_info = CTX->lookup_action_info( $item ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $self = $class->_create_from_config( $action_info ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # ...or nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # TODO: get rid of this? do we ever need to create an action without a name? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 2 | $self = bless( {}, $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # ...pickup messages deposited in the request... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | my $action_msg_name = $self->message_name || $self->name; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->message_name || $self->name
MC/DC0%0/2
$self->message_name || $self->name
$self->message_name
$self->name
Truth table33%1/3
A || B
A= $self->message_nameB= $self->name
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | ▶ | if ( CTX and $action_msg_name ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
CTX() and $action_msg_name
MC/DC0%0/2
CTX() and $action_msg_name
CTX()
$action_msg_name
Truth table33%1/3
A and B
A= CTX()B= $action_msg_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $request = CTX->request; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if ( $request and my $messages = $request->action_messages( $action_msg_name ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$request and my $messages = $request->action_messages($action_msg_name)
MC/DC0%0/2
$request and my $messages = $request->action_messages($action_msg_name)
$request
my $messages = $request->action_messages($action_msg_name)
Truth table0%0/3
A and B
A= $requestB= my $messages = $request->action_messages($action_msg_name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | while ( my ( $msg_name, $msg ) = each %{ $messages } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $self->add_view_message( $msg_name => $msg ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # ...these will override any previous assignments | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 2 | ▶ | if ( $props->{REQUEST_URL} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $self->_set_url( $props->{REQUEST_URL} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | $self->property_assign( $props ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | $self->param_assign( $props ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | return $self->init(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # Cache for classes required (don't require them more than necessary) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 87 | my %CLASSES_USED = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # Cache for actions created from configuration. We clone an entry once | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # it is created... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 87 | my %CONFIG_ACTIONS = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | sub _create_from_config { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_from_config: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my ( $class, $action_info ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | $log ||= get_logger( LOG_ACTION ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | if ( my $redir_action = $action_info->{redir} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my $config = CTX->lookup_action_info( $redir_action ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | return $class->_create_from_config( $config ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | my $name = lc $action_info->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | unless ( $CONFIG_ACTIONS{ $name } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | $log->debug( "Action from configuration has not yet been created for ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | "'$name', creating..." ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $impl_class = $action_info->{class}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if ( $impl_class ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | unless ( $CLASSES_USED{ $impl_class } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | eval "require $impl_class"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my $msg = "Cannot include library '$impl_class' to " . | |||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | "implement action '$name': $@"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $log->error( $msg ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | oi_error $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $CLASSES_USED{ $impl_class }++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | elsif ( my $action_type = $action_info->{action_type} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $impl_class = $class->get_factory_class( $action_type ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | $log->debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | $log->debug( "Got class '$impl_class' from action ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | "type '$action_type'" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | unless ( $impl_class ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $log->error( "Implementation class not found for action ", | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | "'$name' [class: $action_info->{class}] ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | "[type: $action_info->{action_type}]" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | oi_error "Action configuration for $name has no 'class' ", | |||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | "or 'action_type' defined"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | my $self = bless( {}, $impl_class ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $self->_set_name( $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # TODO: See if we can use '$action_info->{url_primary}' at | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # this point... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | my $url = $action_info->{url} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | || $action_info->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$action_info->{'url'} || $action_info->{'name'}
MC/DC0%0/2
$action_info->{'url'} || $action_info->{'name'}
$action_info->{'url'}
$action_info->{'name'}
Truth table0%0/3
A || B
A= $action_info->{'url'}B= $action_info->{'name'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $self->_set_url( $url ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $self->property_assign( $action_info ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $self->param_assign( $action_info ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | $log->debug( "Assigned properties and parameters from config" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # Store for later use so we don't have to recreate (premature | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # optimization? we'll see -- a profile toward the end of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | # 1.99_04 showed quite a bit of time spent in this method) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $CONFIG_ACTIONS{ $name } = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | return $CONFIG_ACTIONS{ $name }->clone; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | ▶ | sub init { return $_[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my ( $self, $props ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | $log ||= get_logger( LOG_ACTION ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | $log->debug( "Creating new action from existing action ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | "named '", $self->name, "' '", ref( $self ), "'" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $new = bless( {}, ref( $self ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $new->_set_name( $self->name ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $new->property_assign( $self->property ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $new->param_assign( $self->param ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if ( $props->{REQUEST_URL} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $self->_set_url( $props->{REQUEST_URL} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | $new->property_assign( $props ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $new->param_assign( $props ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | return $new->init(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # RUN | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: not called CC=21 SCAR=61.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my ( $self, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | $log ||= get_logger( LOG_ACTION ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | $log->debug( "Executing action '", $self->name, "'" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | $params ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$params ||= {}
MC/DC0%0/1
$params ||= {}
$params
Truth table0%0/2
A
A= $params
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | # All properties and parameters passed in become part of the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | # action itself | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $self->property_assign( $params ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $self->param_assign( $params ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # Ensure we have a task, that it is valid and that this user has | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # the security clearance to run it. Each of these find/check | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # methods will throw an exception if the action does not pass | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | unless ( $self->task ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | $log->debug( "Property 'task' not defined, calling ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | "_find_task() to get task from action" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $self->task( $self->_find_task ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my $item_desc = '[' . $self->name . ': ' . $self->task . ']'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # These checks will die if they fail -- let the error bubble up | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | $self->_check_task_validity; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | $log->debug( "Action $item_desc is valid, continuing" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $self->_check_security; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | $log->debug( "Action $item_desc security checked, continuing" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | # Assign any additional URL parameters -- do this before the cache | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # check to ensure that's consistent (it discriminates based on | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # param values) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my @url_params = $self->_get_url_additional_names; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | if ( scalar @url_params ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $request = CTX->request; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if ( $request ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my @url_values = $request->param_url_additional; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my $param_count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | foreach my $value ( @url_values ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | next unless ( $url_params[ $param_count ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $self->param( $url_params[ $param_count ], $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $param_count++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | my $cached_content = $self->_check_cache; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | if ( $cached_content ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $self->notify_observers( 'cache hit', \$cached_content ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | return $cached_content; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | $log->debug( "Cached data not found for $item_desc, continuing" ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $method_ref = $self->_find_task_method; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | $log->debug( "Found task method for $item_desc ok, running" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my $content = eval { $self->$method_ref }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $log->warn( "Caught error from task $item_desc: $@" ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $content = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | $log->debug( "Task $item_desc executed ok, excuting filters" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | $self->notify_observers( 'filter', \$content ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | $log->debug( "Filters for $item_desc ran ok, checking cacheable" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my $cache_expire = $self->_is_using_cache; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | if ( $cache_expire ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | $log->debug( "This content is cacheable and has expiration ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | "'$cache_expire'; caching content..." ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $self->_set_cached_content( $content, $cache_expire ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | $log->debug( "Content from $item_desc not cacheable" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | return $content; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | sub forward { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
forward: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my ( $self, $new_action ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | # TODO: If we standardize on copying 'core' properties | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # from one action to another, add it here | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | return $new_action->execute; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | sub _get_url_additional_names { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_url_additional_names: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my $additional = $self->url_additional; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | return unless ( $additional ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my ( @items ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my $task = $self->task; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | if ( ref $additional eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | @items = @{ $additional }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | elsif ( ref $additional eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | my $base = $additional->{ $task } || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | $additional->{DEFAULT} || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | $additional->{default}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$additional->{$task} || $additional->{'DEFAULT'} || $additional->{'default'}
$additional->{$task} or $additional->{"DEFAULT"}
MC/DC0%0/3
$additional->{$task} || $additional->{'DEFAULT'} || $additional->{'default'}
$additional->{$task}
$additional->{"DEFAULT"}
$additional->{'default'}
Truth table0%0/4
A or B || C
A= $additional->{$task}B= $additional->{"DEFAULT"}C= $additional->{'default'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | if ( $base and ref $base eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$base and ref $base eq "ARRAY"
MC/DC0%0/2
$base and ref $base eq "ARRAY"
$base
ref $base eq "ARRAY"
Truth table0%0/3
A and B
A= $baseB= ref $base eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | @items = @{ $base }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | elsif ( $base ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | @items = ( $base ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | @items = ( $additional ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | return @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # TASK | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | sub _find_task { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_task: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | $log ||= get_logger( LOG_ACTION ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | # NOTE: a defined 'method' in the action will ALWAYS override a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | # task | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | if ( my $method = $self->method ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | $log->debug( "Found task '$method' in property 'method'" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | return $self->task( $method ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | if ( my $task = $self->task ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | $log->debug( "Found task '$task' in property 'task'" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | return $self->task; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | my $default_task = $self->task_default; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | if ( $default_task ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | $log->debug( "Found task '$default_task' in property ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | "'task_default'" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | return $self->task( $default_task ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | oi_error "Cannot find task to execute for '", $self->name, "'"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | # Ensure that the task assigned is valid: if not throw an | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # exception. There must be a task defined by this point. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | sub _check_task_validity { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_task_validity: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | my $check_task = lc $self->task; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | $log ||= get_logger( LOG_ACTION ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | unless ( $check_task ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | my $msg = "No task defined, cannot check validity"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $log->error( $msg ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | oi_error $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | if ( $check_task =~ /^_/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | $log->error( "Task $check_task invalid, cannot begin with ", | |||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | "underscore" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | oi_error "Tasks may not begin with an underscore"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | # See if task has been specified in valid/invalid list | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | my $is_invalid = grep { $check_task eq $_ } @{ $self->task_invalid || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->task_invalid || []
MC/DC0%0/1
$self->task_invalid || []
$self->task_invalid
Truth table0%0/2
A
A= $self->task_invalid
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | if ( $is_invalid ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | $log->error( "Task $check_task explicitly forbidden in config" ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | oi_error "Task is forbidden"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | my $task_valid = $self->task_valid || []; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->task_valid || []
MC/DC0%0/1
$self->task_valid || []
$self->task_valid
Truth table0%0/2
A
A= $self->task_valid
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | if ( scalar @{ $task_valid } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | unless ( grep { $check_task eq $_ } @{ $task_valid } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | $log->error( "Valid tasks enumerated and $check_task not member" ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | oi_error "Task is not specified in action property 'task_valid'"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | # See if 'handler()' exists in the class (or parent class) we're | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | # calling and return that coderef; otherwise if the task method | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | # actually exists return that coderef. If not, throw an exception. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | sub _find_task_method { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_task_method: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | my $task = $self->task; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | $log ||= get_logger( LOG_ACTION ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | if ( my $method = $ACTION_TASK_METHODS{ $self->name }->{ $task } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | $log->debug( "Cached method found for task $task" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | return $method | |||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | foreach my $method_try ( ( 'handler', $task ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | if ( $PROPS{ $method_try } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | $log->error( "PLEASE NOTE: You tried to execute the action task ", | |||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | "[$task] but this is one of the action properties. ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | "No content will be returned for this task." ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | if ( my $method = $self->can( $method_try ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | $ACTION_TASK_METHODS{ $self->name }->{ $task } = $method; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | $log->debug( "Stored method in cache for task $task" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | return $method; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $log->error( "Cannot find method for task $task" ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | oi_error "Cannot find valid method in [", ref( $self ), "] for task [$task]"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | # SECURITY | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | sub _check_security { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_security: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | $log ||= get_logger( LOG_ACTION ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | unless ( $self->security_level ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | $self->security_level( $self->_find_security_level ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | return $self->security_level unless ( $self->is_secure ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | my $action_security = $self->security; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | unless ( $action_security ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | $log->error( "Secure action, no security configuration" ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | oi_error "Configuration error: action is secured but no ", | |||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | "security requirements configured"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | my ( $required_level ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | # NOTE: values in $action_security have already been translated to | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | # security levels by OI2::Config::Initializer::_action_security_level() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | # at server startup. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | # specify security per task... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | my $task = $self->task; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | if ( ref $action_security eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | $required_level = $action_security->{ $task } || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | $action_security->{DEFAULT} || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | $action_security->{default}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$action_security->{$task} || $action_security->{'DEFAULT'} || $action_security->{'default'}
$action_security->{$task} or $action_security->{"DEFAULT"}
MC/DC0%0/3
$action_security->{$task} || $action_security->{'DEFAULT'} || $action_security->{'default'}
$action_security->{$task}
$action_security->{"DEFAULT"}
$action_security->{'default'}
Truth table0%0/4
A or B || C
A= $action_security->{$task}B= $action_security->{"DEFAULT"}C= $action_security->{'default'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | # specify security for entire action... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $required_level = $action_security; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | unless ( defined $required_level ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | $log->is_info && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | $log->info( "Assigned security level WRITE to task ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | "'$task' since no security requirement found" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | $required_level = SEC_LEVEL_WRITE; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | $self->security_required( $required_level ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | my $action_level = $self->security_level; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | if ( $required_level > $action_level ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | my $msg = sprintf( "Security check for '%s' '%s' failed", | |||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | $self->name, $task ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | $log->warn( "$msg [required: $required_level] ", | |||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | "[found: $action_level]" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | oi_security_error $msg, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | { security_required => $required_level, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | security_found => $action_level }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | return $self->security_level; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | # Find the level for this user/group and this action | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | sub _find_security_level { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_security_level: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | $log ||= get_logger( LOG_ACTION ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | unless ( $self->is_secure ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | $log->debug( sprintf( "Action '%s' not secured assigning " . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | "default level.", $self->name ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | return DEFAULT_ACTION_SECURITY; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | # TODO: Dependency on object_id '0' sucks | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | my $found_level = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | CTX->check_security({ class => ref( $self ), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | object_id => '0' }) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | $log->error( "Error in check_security: $@" ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | oi_error "Cannot lookup authorization for action: $@"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | $log->debug( "Found security level $found_level" ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | return $found_level; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # GENERATE CONTENT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | sub generate_content { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_content: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my ( $self, $content_params, $source, $template_params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | $log ||= get_logger( LOG_ACTION ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | $log->debug( "Generating content for [", $self->name, ": ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | $self->task, "]" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | $content_params->{ACTION} = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | $content_params->{action_messages} = $self->view_messages; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | if ( ref( $source ) eq 'HASH' and scalar keys %{ $source } == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $source eq "HASH" and scalar keys %{$source;} == 0
MC/DC0%0/2
ref $source eq "HASH" and scalar keys %{$source;} == 0
ref $source eq "HASH"
scalar keys %{$source;} == 0
Truth table0%0/3
A and B
A= ref $source eq "HASH"B= scalar keys %{$source;} == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | $source = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | $source ||= $self->_get_template_source_from_config; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$source ||= $self->_get_template_source_from_config
MC/DC0%0/2
$source ||= $self->_get_template_source_from_config
$source
$self->_get_template_source_from_config
Truth table0%0/3
A ||= B
A= $sourceB= $self->_get_template_source_from_config
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | my $generator = CTX->content_generator( $self->content_generator ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | return $generator->generate( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | $template_params, $content_params, $source ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | # grab the template source from the configuration key | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | # 'template_source', handling per-task configuration as well as | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # message key lookups | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | sub _get_template_source_from_config { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_template_source_from_config: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | my $task = $self->task; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | my $source_info = $self->template_source; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | unless ( $source_info ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | my $msg = "No template source specified in config, " . | |||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | "no source returned for task '$task'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | $log->error( $msg ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | oi_error $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my ( $task_template_source ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | if ( ref $source_info eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | $task_template_source = $source_info->{ $task }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | unless ( $task_template_source ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | my $msg = "No template source in config for task '$task'"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | $log->error( $msg ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | oi_error $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | ▶ | $log->debug( "Found '$task_template_source' template ", | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | "for '$task' task" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | # assume we're using the same template for all tasks in action; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | # typically when we specify a 'task' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | $log->debug( "Found '$source_info' template for all ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | "tasks in action" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | $task_template_source = $source_info | |||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | $log->debug( "Found template source from action: ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | "'$task_template_source'" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | my ( $msg_key ) = $task_template_source =~ /^msg:(.*)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | return ( $msg_key ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | ? { message_key => $msg_key } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | : { name => $task_template_source }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | sub _msg { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_msg: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | my ( $self, $key, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | return CTX->request->language_handle->maketext( $key, @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | # CACHING | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | # Subclasses override | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | sub initialize_cache_params { return undef } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initialize_cache_params: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | # Property: Just ensure that every value is a number; also allow | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | # simple time substitutions (e.g., '180m' or '3h' instead of '10800' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | # seconds). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 7 | ▶ | sub cache_expire { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cache_expire: called CC=6 SCAR=18.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 7 | my ( $self, $cache_info ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 7 | ▶ | if ( ref $cache_info eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 2 | my %new_info = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 2 | foreach my $task ( keys %{ $cache_info } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 5 | my $time_spec = $cache_info->{ $task }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 5 | $new_info{ $task } = OpenInteract2::Util | |||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | ->time_duration_as_seconds( $time_spec ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 2 | $self->{cache_expire} = \%new_info; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | elsif ( $cache_info ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | my $cache_time = OpenInteract2::Util | |||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | ->time_duration_as_seconds( $cache_info ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | $self->{cache_expire} = { CACHE_ALL_KEY() => $cache_time }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 7 | ▶ | if ( $cache_info ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | $log->debug( "Assigned cache expiration for ", $self->name, ": ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | join( '; ', map { "$_ = $self->{cache_expire}{ $_ }" } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | keys %{ $self->{cache_expire} } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 7 | return $self->{cache_expire}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | # Since we can't be sure what's affected by a change that would prompt | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | # this call, just clear out all cache entries for this action. (For | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | # instance, if a news object is removed we don't want to keep | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | # displaying the old copy in the listing.) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | sub clear_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_cache: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | ▶ | $log ||= get_logger( LOG_ACTION ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | my $cache = CTX->cache; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | return unless ( $cache ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | my $class = ref( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | ▶ | $log->is_info && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | $log->info( "Trying to clear cache for items in class [$class]" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | my $tracking = $cache->get({ key => CACHE_CLASS_KEY }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | ▶ | unless ( ref $tracking eq 'HASH' and scalar keys %{ $tracking } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
ref $tracking eq "HASH" and scalar keys %{$tracking;}
MC/DC0%0/1
ref $tracking eq "HASH" and scalar keys %{$tracking;}
ref $tracking eq "HASH"
Truth table0%0/2
A
A= ref $tracking eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | $log->is_info && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | $log->info( "Nothing yet tracked, nothing to clear" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | my $num_cleared = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | ▶ | my $keys = $tracking->{ $class } || []; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$tracking->{$class} || []
MC/DC0%0/1
$tracking->{$class} || []
$tracking->{$class}
Truth table0%0/2
A
A= $tracking->{$class}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | foreach my $cache_key ( @{ $keys } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | $log->is_debug && $log->debug( "Clearing key '$cache_key'" ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | $cache->clear({ key => $cache_key }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | $num_cleared++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | $tracking->{ $class } = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | $cache->set({ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | key => CACHE_CLASS_KEY, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | data => $tracking | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | ▶ | $log->is_debug && $log->debug( "Tracking data saved back to cache" ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | ▶ | $log->is_info && $log->info( "Finished clearing cache for '$class'" ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | return $num_cleared; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | ▶ | sub _is_using_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_using_cache: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | my $expire = $self->cache_expire; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | unless ( ref $expire eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | ▶ | my $expire_time = $expire->{ $self->task } || $expire->{ CACHE_ALL_KEY() } || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$$expire{$self->task} || $expire->{'__ALL__'} || ''
$$expire{$self->task} or $expire->{"__ALL__"}
MC/DC0%0/2
$$expire{$self->task} || $expire->{'__ALL__'} || ''
$$expire{$self->task}
$expire->{"__ALL__"}
Truth table0%0/3
A or B
A= $$expire{$self->task}B= $expire->{"__ALL__"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | $log->debug( "Action/task ", $self->name, "/", $self->task, " ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | "has cache expiration: ", $expire_time ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | return $expire_time; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | sub _check_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_cache: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | ▶ | return undef unless ( $self->_is_using_cache ); # ...not using cache | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | ▶ | return undef if ( CTX->request->auth_is_admin ); # ...is admin | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | my $cache = CTX->cache; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | ▶ | return undef unless ( $cache ); # ...no cache available | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | my $cache_key = $self->_create_cache_key; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | ▶ | return undef unless ( $cache_key ); # ...no cache key | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | return $cache->get({ key => $cache_key }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | sub _create_cache_key { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_cache_key: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | my $key = join( '-', 'action', $self->name, $self->task ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | my $cache_param = $self->_cache_param_by_task; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | ▶ | unless ( scalar @{ $cache_param } > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | return $key; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | my $set_cache_params = $self->initialize_cache_params; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | my $request = CTX->request; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | foreach my $param_name ( @{ $cache_param } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | ▶ | my $value = $set_cache_params->{ $param_name } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$set_cache_params->{$param_name} || $self->param($param_name) || $request->param($param_name) || $self->_get_cache_default_param($param_name)
$set_cache_params->{$param_name} or $self->param($param_name) or $request->param($param_name)
$set_cache_params->{$param_name} or $self->param($param_name)
MC/DC0%0/4
$set_cache_params->{$param_name} || $self->param($param_name) || $request->param($param_name) || $self->_get_cache_default_param($param_name)
$set_cache_params->{$param_name}
$self->param($param_name)
$request->param($param_name)
$self->_get_cache_default_param($param_name)
Truth table0%0/5
A or B or C || D
A= $set_cache_params->{$param_name}B= $self->param($param_name)C= $request->param($param_name)D= $self->_get_cache_default_param($param_name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | || $self->param( $param_name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | || $request->param( $param_name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | || $self->_get_cache_default_param( $param_name ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | $key .= ";$param_name=$value"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | return $key; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 87 | my %CACHE_PARAM_DEFAULTS = map { $_ => 1 } qw( user_id theme_id ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | ▶ | sub _get_cache_default_param { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_cache_default_param: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | my ( $self, $param_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | ▶ | return undef unless ( $CACHE_PARAM_DEFAULTS{ $param_name } ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | my $request = CTX->request; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | ▶ | if ( $param_name eq 'user_id' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | return $request->auth_user->id; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | elsif ( $param_name eq 'theme_id' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | return $request->theme->id; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | ▶ | sub _set_cached_content { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_cached_content: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | my ( $self, $content, $expiration ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | ▶ | $log ||= get_logger( LOG_ACTION ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | my $cache = CTX->cache; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | ▶ | unless ( $cache ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | $log->warn( "No cache object returned from content; cannot cache ", | |||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | "content from action" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | my $key = $self->_create_cache_key(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | $cache->set({ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | key => $key, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | data => $content, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | expire => $expiration | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | # Now set the tracking data so we can expire when needed | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | ▶ | my $tracking = $cache->get({ key => CACHE_CLASS_KEY }) || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$cache->get({'key', 'class_cache_track'}) || {}
MC/DC0%0/1
$cache->get({'key', 'class_cache_track'}) || {}
$cache->get({'key', 'class_cache_track'})
Truth table0%0/2
A
A= $cache->get({'key', 'class_cache_track'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | my $class = ref( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | push @{ $tracking->{ $class } }, $key; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | $log->debug( "Adding tracking cache key '$key' to class '$class'" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | $cache->set({ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | key => CACHE_CLASS_KEY, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | data => $tracking | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | # ALWAYS return an arrayref, even if it's empty; order is ensured at | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | # startup (see OI2::Setup::_assign_action_info) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | ▶ | sub _cache_param_by_task { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cache_param_by_task: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | my $task = $self->task; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | ▶ | return [] unless ( $task ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | my $params = $self->cache_param; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | ▶ | return [] unless ( ref $params eq 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | ▶ | return $params->{ $task } || []; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$params->{$task} || []
MC/DC0%0/1
$params->{$task} || []
$params->{$task}
Truth table0%0/2
A
A= $params->{$task}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | # PROPERTIES | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | # The 'name' and 'url' properties should not be set by the client, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | # only by the constructor; they are read-only -- any parameters passed | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | # will be ignored. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | # See 'cache_expire' as well | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 3 | ▶ | sub name { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 3 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 3 | return $self->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | sub _set_name { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_name: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | ▶ | $self->{name} = $name if ( $name ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | return $self->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 1 | ▶ | sub url { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
url: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 1 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 1 | return $self->{url}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | ▶ | sub _set_url { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_url: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | my ( $self, $url ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | ▶ | $self->{url} = $url if ( $url ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | return $self->{url}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 4 | ▶ | sub is_secure { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_secure: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 4 | my ( $self, $setting ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 4 | ▶ | if ( $setting ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 2 | ▶ | $setting = 'no' unless ( $setting eq 'yes' ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 2 | $self->{is_secure} = $setting; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 4 | ▶ | $self->{is_secure} ||= 'no'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"is_secure"} ||= "no"
MC/DC0%0/1
$self->{"is_secure"} ||= "no"
$self->{"is_secure"}
Truth table50%1/2
A
A= $self->{"is_secure"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 4 | ▶ | return ( $self->{is_secure} eq 'yes' ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | # read-only | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | ▶ | sub package { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
package: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | my $package_name = $self->package_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | ▶ | return undef unless ( $package_name ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | return CTX->repository->fetch_package( $package_name ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | # Assign the object properties from the params passed in; the rest of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | # the parameters are instance parameters that we won't know in | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | # advance, accessible via param() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 3 | ▶ | sub property_assign { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
property_assign: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 3 | my ( $self, $props ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 3 | ▶ | return unless ( ref $props eq 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 3 | ▶ | while ( my ( $field, $value ) = each %{ $props } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | # These aren't defined in %PROPS -- let them deal with | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | # undefined values | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 8 | ▶ | if ( $field =~ /^(cache_expire|is_secure|name)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 1 | $self->$field( $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | # ...everything else in %PROPS with a defined value (use | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | # property_clear to set to undef) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | ▶ | elsif ( $PROPS{ $field } and defined $value ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$PROPS{$field} and defined $value
MC/DC50%1/2
$PROPS{$field} and defined $value
$PROPS{$field}
defined $value
Truth table66%2/3
A and B
A= $PROPS{$field}B= defined $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 5 | $self->$field( $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | # Do a generic set if property and value given; return a hashref of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | # all properties | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 3 | ▶ | sub property { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
property: called CC=4 SCAR=15.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 3 | my ( $self, $prop, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 3 | ▶ | if ( $prop and $PROPS{ $prop } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$prop and $PROPS{$prop}
MC/DC0%0/2
$prop and $PROPS{$prop}
$prop
$PROPS{$prop}
Truth table33%1/3
A and B
A= $propB= $PROPS{$prop}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 3 | ▶ | $self->{ $prop } = $value if ( $value ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 3 | return $self->{ $prop }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | return { map { $_ => $self->{ $_ } } $self->property_names }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | # All items in %PROPS plus special properties we handle separately; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | # 'cache_expire' is handled in the caching section | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | ▶ | sub property_names { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
property_names: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | return ( keys %PROPS, 'is_secure', 'name', 'cache_expire' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | ▶ | sub property_info { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
property_info: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | %PROPS, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | is_secure => 'Whether this action has security (yes/no)', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | name => 'Unique name of this action', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | cache_expire => 'Time content should be cached, per-task', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | # Clear out a property (since passing undef for a set won't work) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 1 | ▶ | sub property_clear { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
property_clear: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 1 | my ( $self, $prop ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 1 | return delete $self->{ $prop }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | # PARAMS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 3 | ▶ | sub get_skip_params { return %PROPS } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_skip_params: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | ▶ | sub param_from_request { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
param_from_request: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | my ( $self, @params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | my $req = CTX->request; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | for ( @params ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | $self->param( $_, scalar $req->param( $_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | # shortcuts... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | ▶ | sub add_error { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | my ( $self, @msg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | my $err = join( '', @msg ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 0 | $self->param_add( error_msg => $err ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | return $err; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | ▶ | sub add_status { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_status: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | my ( $self, @msg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | my $status = join( '', @msg ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | $self->param_add( status_msg => $status ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | return $status; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | ▶ | sub add_error_key { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_error_key: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | my ( $self, $key, @params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | ▶ | $log->is_debug && $log->debug( "Adding error with key '$key'" ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | return $self->add_error( $self->_msg( $key, @params ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | ▶ | sub add_status_key { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_status_key: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | my ( $self, $key, @params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | ▶ | $log->is_debug && $log->debug( "Adding status with key '$key'" ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | return $self->add_status( $self->_msg( $key, @params ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | ▶ | sub clear_error { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | $self->param_clear( 'error_msg' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | ▶ | sub clear_status { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_status: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | $self->param_clear( 'status_msg' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | # confusing name -- the title would suggest we want the message key | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | # first, but we want to also pass along optional arguments to the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | # message key and they should be next to the key argument... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | ▶ | sub message_from_key_or_param { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
message_from_key_or_param: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | my ( $self, $param_name, $message_key, @key_args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | ▶ | $log ||= get_logger( LOG_ACTION ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | ▶ | if ( $message_key and $self->param( $message_key ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$message_key and $self->param($message_key)
MC/DC0%0/2
$message_key and $self->param($message_key)
$message_key
$self->param($message_key)
Truth table0%0/3
A and B
A= $message_keyB= $self->param($message_key)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | my $language_handle = CTX->request->language_handle; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | ▶ | $log->is_debug | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | && $log->debug( "Creating message from '$message_key' field '". | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | $self->param($message_key) ."' with args '@key_args'\n" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | my $msg = $language_handle->maketext( $self->param( $message_key ), @key_args ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | ▶ | return $msg if ( $msg ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | return $self->param( $param_name ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | ▶ | sub view_messages { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
view_messages: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | my ( $self, $messages ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | ▶ | if ( ref $messages eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | $self->{_view_msg} = $messages | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | ▶ | $self->{_view_msg} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"_view_msg"} ||= {}
MC/DC0%0/1
$self->{"_view_msg"} ||= {}
$self->{"_view_msg"}
Truth table0%0/2
A
A= $self->{"_view_msg"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | return $self->{_view_msg}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | ▶ | sub add_view_message { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_view_message: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 0 | my ( $self, $msg_name, $msg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | return $self->{_view_msg}{ $msg_name } = $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | # URL | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | ▶ | sub create_url { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_url: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | my ( $self, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | # We may want to pass an empty TASK on purpose, so don't just | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | # check to see if TASK exists... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | my $task = ( exists $params->{TASK} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | ▶ | ? $params->{TASK} : $self->task; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | delete $params->{TASK}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 0 | return OpenInteract2::URL->create_from_action( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | $self->name, $task, $params ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | # NOTE: DO NOT CHANGE THE ORDER OF PROCESSING HERE WITHOUT CHANGING | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | # DOCS IN 'MAPPING URL TO ACTION'. This includes checking 'url' first | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | # and the order of the default urls generates (lc, uc, ucfirst) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | ▶ | sub get_dispatch_urls { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_dispatch_urls: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | ▶ | $log ||= get_logger( LOG_ACTION ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | $log->debug( "Find dispatch URLs for [", $self->name, "]" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | my $no_urls = $self->url_none; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | ▶ | if ( defined $no_urls and $no_urls =~ /^\s*(yes|true)\s*$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $no_urls and $no_urls =~ /^\s*(yes|true)\s*$/
MC/DC0%0/2
defined $no_urls and $no_urls =~ /^\s*(yes|true)\s*$/
defined $no_urls
$no_urls =~ /^\s*(yes|true)\s*$/
Truth table0%0/3
A and B
A= defined $no_urlsB= $no_urls =~ /^\s*(yes|true)\s*$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | ▶ | $log->is_debug && $log->debug( "...has no URL" ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 0 | return []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 0 | my @urls = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 0 | ▶ | if ( $self->url ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | push @urls, $self->url; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | $log->debug( "...has spec URL [", $self->url, "]" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | push @urls, lc $self->name, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | uc $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | ucfirst lc $self->name; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | $log->debug( "...has named URLs [", join( '] [', @urls ), ']' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 0 | ▶ | if ( $self->url_alt ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | my @alternates = ( ref $self->url_alt eq 'ARRAY' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | ▶ | ? @{ $self->url_alt } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | : ( $self->url_alt ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | push @urls, @alternates; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 0 | ▶ | $log->is_debug && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | $log->debug( "...has alt URLs [", join( '] [', @alternates ), ']' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | return \@urls; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | # Cleanup after ourselves | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 2 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 2 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 2 | $self->delete_observers; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | # SHORTCUTS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 0 | ▶ | sub context { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
context: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 0 | die 'HEY! Change $action->context call at ', join( ' / ', caller ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | # FACTORY | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 0 | ▶ | sub factory_log { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
factory_log: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 0 | my ( $self, @msg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 0 | get_logger( LOG_ACTION )->info( @msg ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | ▶ | sub factory_error { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
factory_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 0 | my ( $self, @msg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 0 | get_logger( LOG_ACTION )->error( @msg ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 0 | die @msg, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 87 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||